mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Get test passing
This commit is contained in:
parent
d19aa016aa
commit
764a5bac56
@ -11,6 +11,17 @@ describe('MetaMaskController', function () {
|
||||
unlockAccountMessage: noop,
|
||||
showUnapprovedTx: noop,
|
||||
platform: {},
|
||||
encryptor: {
|
||||
encrypt: function(password, object) {
|
||||
console.log('encrypting ', object)
|
||||
this.object = object
|
||||
return Promise.resolve()
|
||||
},
|
||||
decrypt: function () {
|
||||
console.log('decrypting')
|
||||
return Promise.resolve(this.object)
|
||||
}
|
||||
},
|
||||
// initial state
|
||||
initState: clone(firstTimeState),
|
||||
})
|
||||
@ -28,20 +39,30 @@ describe('MetaMaskController', function () {
|
||||
describe('Metamask Controller', function () {
|
||||
assert(metamaskController)
|
||||
|
||||
beforeEach(function () {
|
||||
sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
metamaskController.keyringController.createNewVaultAndKeychain.restore()
|
||||
})
|
||||
|
||||
describe('#createNewVaultAndKeychain', function () {
|
||||
it('can only create new vault on keyringController once', async function () {
|
||||
|
||||
const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
|
||||
|
||||
const expectation = sinon.mock(metamaskController.keyringController)
|
||||
.expects('createNewVaultAndKeychain').once()
|
||||
|
||||
const password = 'a-fake-password'
|
||||
|
||||
const first = await metamaskController.createNewVaultAndKeychain(password)
|
||||
console.log('FIRST ONE RETURNED:')
|
||||
console.dir(first)
|
||||
const second = await metamaskController.createNewVaultAndKeychain(password)
|
||||
console.log('SECOND ONE RETURNED:')
|
||||
console.dir(second)
|
||||
|
||||
assert(metamaskController.keyringController.createNewVaultAndKeychain.calledOnce)
|
||||
|
||||
expectation.verify()
|
||||
selectStub.reset()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user