2017-05-04 23:35:10 +02:00
|
|
|
// var jsdom = require('mocha-jsdom')
|
2016-05-26 00:39:18 +02:00
|
|
|
var assert = require('assert')
|
2017-05-04 23:35:10 +02:00
|
|
|
// var freeze = require('deep-freeze-strict')
|
2016-05-26 00:39:18 +02:00
|
|
|
var path = require('path')
|
|
|
|
var sinon = require('sinon')
|
|
|
|
|
2019-03-22 00:03:30 +01:00
|
|
|
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js'))
|
|
|
|
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js'))
|
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')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|