aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-12-06 00:41:59 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-12-07 13:11:52 +0800
commitec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7 (patch)
tree4a89f70ed4481c78628f139676f92225f60e15fe /test
parent2b1f2557c7dbd589724fd690ec72f789f9650e3c (diff)
downloadtangerine-wallet-browser-ec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7.tar
tangerine-wallet-browser-ec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7.tar.gz
tangerine-wallet-browser-ec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7.tar.bz2
tangerine-wallet-browser-ec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7.tar.lz
tangerine-wallet-browser-ec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7.tar.xz
tangerine-wallet-browser-ec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7.tar.zst
tangerine-wallet-browser-ec6c3c33bdbe2d90dc71649d0cc5fb3c07d96af7.zip
Merge branch 'master' into NewUI-flat-merge-with-master
Diffstat (limited to 'test')
-rw-r--r--test/integration/lib/mascara-first-time.js59
-rw-r--r--test/unit/metamask-controller-test.js33
2 files changed, 57 insertions, 35 deletions
diff --git a/test/integration/lib/mascara-first-time.js b/test/integration/lib/mascara-first-time.js
index 398ecea0e..515c7f383 100644
--- a/test/integration/lib/mascara-first-time.js
+++ b/test/integration/lib/mascara-first-time.js
@@ -6,23 +6,7 @@ async function runFirstTimeUsageTest (assert, done) {
const app = $('#app-content')
- // recurse notices
- while (true) {
- const button = app.find('button')
- if (button.html() === 'Accept') {
- // still notices to accept
- const termsPage = app.find('.markdown')[0]
- termsPage.scrollTop = termsPage.scrollHeight
- await timeout()
- console.log('Clearing notice')
- button.click()
- await timeout()
- } else {
- // exit loop
- console.log('No more notices...')
- break
- }
- }
+ await skipNotices(app)
await timeout()
@@ -51,28 +35,13 @@ async function runFirstTimeUsageTest (assert, done) {
assert.equal(created.textContent, 'Your unique account image', 'unique image screen')
// Agree button
- const button = app.find('button')[0]
+ let button = app.find('button')[0]
assert.ok(button, 'button present')
button.click()
await timeout(1000)
- // Privacy Screen
- const detail = app.find('.tou__title')[0]
- assert.equal(detail.textContent, 'Privacy Notice', 'privacy notice screen')
- app.find('button').click()
-
- await timeout(1000)
-
-
- // terms of service screen
- const tou = app.find('.tou__title')[0]
- assert.equal(tou.textContent, 'Terms of Use', 'terms of use screen')
- app.find('.tou__body').scrollTop(100000)
- await timeout(1000)
-
- app.find('.first-time-flow__button').click()
- await timeout(1000)
+ await skipNotices(app)
// secret backup phrase
const seedTitle = app.find('.backup-phrase__title')[0]
@@ -156,4 +125,24 @@ function timeout (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time || 1500)
})
-} \ No newline at end of file
+}
+
+async function skipNotices (app) {
+ while (true) {
+ const button = app.find('button')
+ if (button && button.html() === 'Accept') {
+ // still notices to accept
+ const termsPage = app.find('.markdown')[0]
+ if (!termsPage) {
+ break
+ }
+ termsPage.scrollTop = termsPage.scrollHeight
+ await timeout()
+ button.click()
+ await timeout()
+ } else {
+ console.log('No more notices...')
+ break
+ }
+ }
+}
diff --git a/test/unit/metamask-controller-test.js b/test/unit/metamask-controller-test.js
index ef6cae758..fd420a70f 100644
--- a/test/unit/metamask-controller-test.js
+++ b/test/unit/metamask-controller-test.js
@@ -11,6 +11,15 @@ describe('MetaMaskController', function () {
unlockAccountMessage: noop,
showUnapprovedTx: noop,
platform: {},
+ encryptor: {
+ encrypt: function(password, object) {
+ this.object = object
+ return Promise.resolve()
+ },
+ decrypt: function () {
+ return Promise.resolve(this.object)
+ }
+ },
// initial state
initState: clone(firstTimeState),
})
@@ -27,6 +36,30 @@ describe('MetaMaskController', function () {
describe('Metamask Controller', function () {
assert(metamaskController)
+
+ beforeEach(function () {
+ sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
+ })
+
+ afterEach(function () {
+ metamaskController.keyringController.createNewVaultAndKeychain.restore()
+ })
+
+ describe('#createNewVaultAndKeychain', function () {
+ it('can only create new vault on keyringController once', async function () {
+
+ const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
+
+ const password = 'a-fake-password'
+
+ const first = await metamaskController.createNewVaultAndKeychain(password)
+ const second = await metamaskController.createNewVaultAndKeychain(password)
+
+ assert(metamaskController.keyringController.createNewVaultAndKeychain.calledOnce)
+
+ selectStub.reset()
+ })
+ })
})
})