diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/actions/tx_test.js | 1 | ||||
-rw-r--r-- | test/unit/app/controllers/metamask-controller-test.js | 32 | ||||
-rw-r--r-- | test/unit/app/controllers/preferences-controller-test.js | 15 | ||||
-rw-r--r-- | test/unit/ui/app/actions.spec.js | 243 | ||||
-rw-r--r-- | test/unit/ui/app/reducers/app.spec.js | 13 | ||||
-rw-r--r-- | test/unit/ui/app/reducers/metamask.spec.js | 36 |
6 files changed, 2 insertions, 338 deletions
diff --git a/test/unit/actions/tx_test.js b/test/unit/actions/tx_test.js index f2f8f1d1c..66378b594 100644 --- a/test/unit/actions/tx_test.js +++ b/test/unit/actions/tx_test.js @@ -35,7 +35,6 @@ describe('tx confirmation screen', function () { actions._setBackgroundConnection({ approveTransaction (_, cb) { cb('An error!') }, cancelTransaction (_, cb) { cb() }, - clearSeedWordCache (cb) { cb() }, getState (cb) { cb() }, }) done() diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index e8e407a7f..effd7c0ce 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -497,8 +497,6 @@ describe('MetaMaskController', function () { }) describe('#verifyseedPhrase', function () { - let seedPhrase, getConfigSeed - it('errors when no keying is provided', async function () { try { await metamaskController.verifySeedPhrase() @@ -509,21 +507,6 @@ describe('MetaMaskController', function () { beforeEach(async function () { await metamaskController.createNewVaultAndKeychain('password') - seedPhrase = await metamaskController.verifySeedPhrase() - }) - - it('#placeSeedWords should match the initially created vault seed', function () { - - metamaskController.placeSeedWords((err, result) => { - if (err) { - console.log(err) - } else { - getConfigSeed = metamaskController.configManager.getSeedWords() - assert.equal(result, seedPhrase) - assert.equal(result, getConfigSeed) - } - }) - assert.equal(getConfigSeed, undefined) }) it('#addNewAccount', async function () { @@ -589,21 +572,6 @@ describe('MetaMaskController', function () { }) }) - describe('#clearSeedWordCache', function () { - it('should set seed words to null', function (done) { - sandbox.stub(metamaskController.preferencesController, 'setSeedWords') - metamaskController.clearSeedWordCache((err) => { - if (err) { - done(err) - } - - assert.ok(metamaskController.preferencesController.setSeedWords.calledOnce) - assert.deepEqual(metamaskController.preferencesController.setSeedWords.args, [[null]]) - done() - }) - }) - }) - describe('#setCurrentLocale', function () { it('checks the default currentLocale', function () { diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 81b152f3d..7e047a2a8 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -496,21 +496,6 @@ describe('preferences controller', function () { }) }) - describe('setSeedWords', function () { - it('should default to null', function () { - const state = preferencesController.store.getState() - assert.equal(state.seedWords, null) - }) - - it('should set the seedWords property in state', function () { - assert.equal(preferencesController.store.getState().seedWords, null) - - preferencesController.setSeedWords('foo bar baz') - - assert.equal(preferencesController.store.getState().seedWords, 'foo bar baz') - }) - }) - describe('#updateRpc', function () { it('should update the rpcDetails properly', () => { preferencesController.store.updateState({frequentRpcListDetail: [{}, { rpcUrl: 'test' }, {}]}) diff --git a/test/unit/ui/app/actions.spec.js b/test/unit/ui/app/actions.spec.js index 34dd6a39b..392321481 100644 --- a/test/unit/ui/app/actions.spec.js +++ b/test/unit/ui/app/actions.spec.js @@ -134,95 +134,25 @@ describe('Actions', () => { }) }) - describe('#confirmSeedWords', () => { - - let clearSeedWordCacheSpy - - afterEach(() => { - clearSeedWordCacheSpy.restore() - }) - - it('shows account page after clearing seed word cache', () => { - - const store = mockStore({}) - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'HIDE_LOADING_INDICATION' }, - { type: 'SHOW_ACCOUNTS_PAGE' }, - ] - - clearSeedWordCacheSpy = sinon.spy(background, 'clearSeedWordCache') - - return store.dispatch(actions.confirmSeedWords()) - .then(() => { - assert.equal(clearSeedWordCacheSpy.callCount, 1) - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - - it('errors in callback will display warning', () => { - const store = mockStore({}) - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'HIDE_LOADING_INDICATION' }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - clearSeedWordCacheSpy = sinon.stub(background, 'clearSeedWordCache') - - clearSeedWordCacheSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.confirmSeedWords()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - describe('#createNewVaultAndRestore', () => { - let createNewVaultAndRestoreSpy, clearSeedWordCacheSpy + let createNewVaultAndRestoreSpy afterEach(() => { createNewVaultAndRestoreSpy.restore() }) - it('clears seed words and restores new vault', () => { + it('restores new vault', () => { const store = mockStore({}) createNewVaultAndRestoreSpy = sinon.spy(background, 'createNewVaultAndRestore') - clearSeedWordCacheSpy = sinon.spy(background, 'clearSeedWordCache') return store.dispatch(actions.createNewVaultAndRestore()) .catch(() => { - assert(clearSeedWordCacheSpy.calledOnce) assert(createNewVaultAndRestoreSpy.calledOnce) }) }) - it('errors when callback in clearSeedWordCache throws', () => { - const store = mockStore() - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - { type: 'HIDE_LOADING_INDICATION' }, - ] - - clearSeedWordCacheSpy = sinon.stub(background, 'clearSeedWordCache') - clearSeedWordCacheSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.createNewVaultAndRestore()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - it('errors when callback in createNewVaultAndRestore throws', () => { const store = mockStore({}) @@ -246,113 +176,6 @@ describe('Actions', () => { }) }) - describe('#createNewVaultAndKeychain', () => { - - let createNewVaultAndKeychainSpy, placeSeedWordsSpy - - afterEach(() => { - createNewVaultAndKeychainSpy.restore() - placeSeedWordsSpy.restore() - }) - - it('calls createNewVaultAndKeychain and placeSeedWords in background', () => { - - const store = mockStore() - - createNewVaultAndKeychainSpy = sinon.spy(background, 'createNewVaultAndKeychain') - placeSeedWordsSpy = sinon.spy(background, 'placeSeedWords') - - return store.dispatch(actions.createNewVaultAndKeychain()) - .then(() => { - assert(createNewVaultAndKeychainSpy.calledOnce) - assert(placeSeedWordsSpy.calledOnce) - }) - }) - - it('displays error and value when callback errors', () => { - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - { type: 'HIDE_LOADING_INDICATION' }, - ] - - createNewVaultAndKeychainSpy = sinon.stub(background, 'createNewVaultAndKeychain') - createNewVaultAndKeychainSpy.callsFake((_, callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.createNewVaultAndKeychain()) - .then(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - - }) - - it('errors when placeSeedWords throws', () => { - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - { type: 'HIDE_LOADING_INDICATION' }, - ] - - placeSeedWordsSpy = sinon.stub(background, 'placeSeedWords') - placeSeedWordsSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.createNewVaultAndKeychain()) - .then(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - - describe('#requestRevealSeed', () => { - - let submitPasswordSpy, placeSeedWordsSpy - - afterEach(() => { - submitPasswordSpy.restore() - }) - - it('calls submitPassword and placeSeedWords from background', () => { - - const store = mockStore() - - submitPasswordSpy = sinon.spy(background, 'submitPassword') - placeSeedWordsSpy = sinon.spy(background, 'placeSeedWords') - - return store.dispatch(actions.requestRevealSeed()) - .then(() => { - assert(submitPasswordSpy.calledOnce) - assert(placeSeedWordsSpy.calledOnce) - }) - }) - - it('displays warning error with value when callback errors', () => { - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((_, callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.requestRevealSeed()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - describe('#requestRevealSeedWords', () => { let submitPasswordSpy @@ -389,68 +212,6 @@ describe('Actions', () => { }) }) - describe('#requestRevealSeed', () => { - - let submitPasswordSpy, placeSeedWordsSpy - - afterEach(() => { - submitPasswordSpy.restore() - placeSeedWordsSpy.restore() - }) - - it('calls submitPassword and placeSeedWords in background', () => { - - const store = mockStore() - - submitPasswordSpy = sinon.spy(background, 'submitPassword') - placeSeedWordsSpy = sinon.spy(background, 'placeSeedWords') - - return store.dispatch(actions.requestRevealSeed()) - .then(() => { - assert(submitPasswordSpy.calledOnce) - assert(placeSeedWordsSpy.calledOnce) - }) - }) - - it('displays warning error message when submitPassword in background errors', () => { - submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((_, callback) => { - callback(new Error('error')) - }) - - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - return store.dispatch(actions.requestRevealSeed()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - - it('errors when placeSeedWords throw', () => { - placeSeedWordsSpy = sinon.stub(background, 'placeSeedWords') - placeSeedWordsSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - return store.dispatch(actions.requestRevealSeed()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - describe('#removeAccount', () => { let removeAccountSpy diff --git a/test/unit/ui/app/reducers/app.spec.js b/test/unit/ui/app/reducers/app.spec.js index 28f5ebb33..6f8dd920c 100644 --- a/test/unit/ui/app/reducers/app.spec.js +++ b/test/unit/ui/app/reducers/app.spec.js @@ -270,18 +270,6 @@ describe('App State', () => { assert.equal(state.isLoading, true) }) - it('shows new vault seed', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_NEW_VAULT_SEED, - value: 'test seed words', - }) - - assert.equal(state.currentView.name, 'createVaultComplete') - assert.equal(state.currentView.seedWords, 'test seed words') - assert.equal(state.transForward, true) - assert.equal(state.isLoading, false) - }) - it('shows new account screen', () => { const state = reduceApp(metamaskState, { type: actions.NEW_ACCOUNT_SCREEN, @@ -437,7 +425,6 @@ describe('App State', () => { }) assert.equal(state.currentView.name, 'accounts') - assert.equal(state.currentView.seedWords, undefined) assert.equal(state.transForward, true) assert.equal(state.isLoading, false) assert.equal(state.warning, null) diff --git a/test/unit/ui/app/reducers/metamask.spec.js b/test/unit/ui/app/reducers/metamask.spec.js index d7876bf39..39caf3e6a 100644 --- a/test/unit/ui/app/reducers/metamask.spec.js +++ b/test/unit/ui/app/reducers/metamask.spec.js @@ -9,32 +9,6 @@ describe('MetaMask Reducers', () => { assert(initState) }) - it('sets revealing seed to true and adds seed words to new state', () => { - const seedWordsState = reduceMetamask({}, { - type: actions.SHOW_NEW_VAULT_SEED, - value: 'test seed words', - }) - - assert.equal(seedWordsState.seedWords, 'test seed words') - assert.equal(seedWordsState.isRevealingSeedWords, true) - }) - - it('shows account page', () => { - const seedWordsState = { - metamask: { - seedwords: 'test seed words', - isRevealing: true, - }, - } - - const state = reduceMetamask(seedWordsState, { - type: actions.SHOW_ACCOUNTS_PAGE, - }) - - assert.equal(state.seedWords, undefined) - assert.equal(state.isRevealingSeedWords, false) - }) - it('unlocks MetaMask', () => { const state = reduceMetamask({}, { type: actions.UNLOCK_METAMASK, @@ -152,16 +126,6 @@ describe('MetaMask Reducers', () => { }) }) - it('shows new vault seed words and sets isRevealingSeedWords to true', () => { - const showNewVaultSeedState = reduceMetamask({}, { - type: actions.SHOW_NEW_VAULT_SEED, - value: 'test seed words', - }) - - assert.equal(showNewVaultSeedState.isRevealingSeedWords, true) - assert.equal(showNewVaultSeedState.seedWords, 'test seed words') - }) - it('shows account detail', () => { const state = reduceMetamask({}, { |