mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Test for failure of the async methods.
This commit is contained in:
parent
20aa135ad8
commit
4b63ec8f1d
@ -39,17 +39,19 @@ describe('MetaMaskController', function () {
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
|
sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
|
||||||
|
sinon.spy(metamaskController.keyringController, 'createNewVaultAndRestore')
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
metamaskController.keyringController.createNewVaultAndKeychain.restore()
|
metamaskController.keyringController.createNewVaultAndKeychain.restore()
|
||||||
|
metamaskController.keyringController.createNewVaultAndRestore.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#createNewVaultAndKeychain', function () {
|
describe('#createNewVaultAndKeychain', function () {
|
||||||
it('can only create new vault on keyringController once', async function () {
|
it('can only create new vault on keyringController once', async function () {
|
||||||
|
|
||||||
const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
|
const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
|
||||||
|
|
||||||
|
|
||||||
const password = 'a-fake-password'
|
const password = 'a-fake-password'
|
||||||
|
|
||||||
const first = await metamaskController.createNewVaultAndKeychain(password)
|
const first = await metamaskController.createNewVaultAndKeychain(password)
|
||||||
@ -60,6 +62,22 @@ describe('MetaMaskController', function () {
|
|||||||
selectStub.reset()
|
selectStub.reset()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
describe('#createNewVaultAndRestore', function () {
|
||||||
|
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
|
||||||
|
// const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
|
||||||
|
|
||||||
|
const password = 'what-what-what'
|
||||||
|
const wrongSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadiu'
|
||||||
|
const rightSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
|
||||||
|
const first = await metamaskController.createNewVaultAndRestore(password, wrongSeed)
|
||||||
|
.catch((e) => {
|
||||||
|
return
|
||||||
|
})
|
||||||
|
const second = await metamaskController.createNewVaultAndRestore(password, rightSeed)
|
||||||
|
|
||||||
|
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user