2020-01-09 04:34:58 +01:00
|
|
|
import assert from 'assert'
|
|
|
|
import sinon from 'sinon'
|
|
|
|
import * as actions from '../../../ui/app/store/actions'
|
|
|
|
import reducers from '../../../ui/app/ducks'
|
2016-05-26 00:39:18 +02:00
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
describe('#unlockMetamask(selectedAccount)', function () {
|
|
|
|
beforeEach(function () {
|
2016-05-26 00:39:18 +02:00
|
|
|
// sinon allows stubbing methods that are easily verified
|
2018-04-04 21:48:30 +02:00
|
|
|
this.sinon = sinon.createSandbox()
|
2016-05-26 00:39:18 +02:00
|
|
|
})
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
afterEach(function () {
|
2016-05-26 00:39:18 +02:00
|
|
|
// sinon requires cleanup otherwise it will overwrite context
|
|
|
|
this.sinon.restore()
|
|
|
|
})
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
describe('after an error', function () {
|
|
|
|
it('clears warning', function () {
|
2016-05-26 00:39:18 +02:00
|
|
|
const warning = 'this is the wrong warning'
|
|
|
|
const account = 'foo_account'
|
|
|
|
const initialState = {
|
|
|
|
appState: {
|
|
|
|
warning: warning,
|
2017-05-04 23:35:10 +02:00
|
|
|
},
|
2016-05-26 00:39:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const resultState = reducers(initialState, actions.unlockMetamask(account))
|
|
|
|
assert.equal(resultState.appState.warning, null, 'warning nullified')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
describe('going home after an error', function () {
|
|
|
|
it('clears warning', function () {
|
2016-05-26 00:39:18 +02:00
|
|
|
const warning = 'this is the wrong warning'
|
2017-05-04 23:35:10 +02:00
|
|
|
// const account = 'foo_account'
|
2016-05-26 00:39:18 +02:00
|
|
|
const initialState = {
|
|
|
|
appState: {
|
|
|
|
warning: warning,
|
2017-05-04 23:35:10 +02:00
|
|
|
},
|
2016-05-26 00:39:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const resultState = reducers(initialState, actions.goHome())
|
|
|
|
assert.equal(resultState.appState.warning, null, 'warning nullified')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|