1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 13:47:06 +01:00
metamask-extension/test/unit/reducers/unlock_vault_test.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

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