mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
2dd7bd6bd0
- When unlocking, the first account is now selected by default and displayed as the main view. - There is now a "CHANGE ACCT" button on the detail view to show the accounts list. - Clicking an account from the accounts list now navigates to the detail view and selects that account. - Config/Info screen "back" buttons now fire a new action, `GO_HOME`, which is configured to navigate to the accountDetail view, putting that logic in one place. - When locking and unlocking again, the first account is always displayed, eventually we should persist the selection.
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
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('#recoverFromSeed(password, seed)', 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()
|
|
})
|
|
|
|
// stub out account manager
|
|
actions._setAccountManager({
|
|
recoverFromSeed(pw, seed, cb) { cb(null, [{}, {}]) },
|
|
})
|
|
|
|
it('sets metamask.isUnlocked to true', function() {
|
|
var initialState = {
|
|
metamask: {
|
|
isUnlocked: false,
|
|
isInitialized: false,
|
|
}
|
|
}
|
|
freeze(initialState)
|
|
|
|
const restorePhrase = 'invite heavy among daring outdoor dice jelly coil stable note seat vicious'
|
|
const password = 'foo'
|
|
const dispatchFunc = actions.recoverFromSeed(password, restorePhrase)
|
|
|
|
var dispatchStub = this.sinon.stub()
|
|
dispatchStub.withArgs({ TYPE: actions.unlockMetamask() }).onCall(0)
|
|
dispatchStub.withArgs({ TYPE: actions.showAccountsPage() }).onCall(1)
|
|
|
|
var action
|
|
var resultingState = initialState
|
|
dispatchFunc((newAction) => {
|
|
action = newAction
|
|
resultingState = reducers(resultingState, action)
|
|
})
|
|
|
|
assert.equal(resultingState.metamask.isUnlocked, true, 'was unlocked')
|
|
assert.equal(resultingState.metamask.isInitialized, true, 'was initialized')
|
|
});
|
|
});
|