diff --git a/test/unit/reducers/unlock_vault_test.js b/test/unit/reducers/unlock_vault_test.js new file mode 100644 index 000000000..b7540af08 --- /dev/null +++ b/test/unit/reducers/unlock_vault_test.js @@ -0,0 +1,51 @@ +var jsdom = require('mocha-jsdom') +var assert = require('assert') +var freeze = require('deep-freeze-strict') +var path = require('path') +var sinon = require('sinon') + +var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js')) +var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js')) + +describe('#unlockMetamask(selectedAccount)', function() { + + beforeEach(function() { + // sinon allows stubbing methods that are easily verified + this.sinon = sinon.sandbox.create() + }) + + afterEach(function() { + // sinon requires cleanup otherwise it will overwrite context + this.sinon.restore() + }) + + describe('after an error', function() { + it('clears warning', function() { + const warning = 'this is the wrong warning' + const account = 'foo_account' + const initialState = { + appState: { + warning: warning, + } + } + + const resultState = reducers(initialState, actions.unlockMetamask(account)) + assert.equal(resultState.appState.warning, null, 'warning nullified') + }) + }) + + describe('going home after an error', function() { + it('clears warning', function() { + const warning = 'this is the wrong warning' + const account = 'foo_account' + const initialState = { + appState: { + warning: warning, + } + } + + const resultState = reducers(initialState, actions.goHome()) + assert.equal(resultState.appState.warning, null, 'warning nullified') + }) + }) +}) diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index a29a8f79c..493246a35 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -152,6 +152,7 @@ function reduceApp(state, action) { privateKey: '', }, transForward: false, + warning: null, }) case actions.SHOW_ACCOUNT_DETAIL: