1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 03:20:23 +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')
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')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
2017-05-04 23:35:10 +02:00
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.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')
})
})
})