diff options
author | Kevin Serrano <kevin.serrano@consensys.net> | 2018-01-04 08:44:14 +0800 |
---|---|---|
committer | Kevin Serrano <kevin.serrano@consensys.net> | 2018-01-04 08:44:14 +0800 |
commit | 4b63ec8f1daaba11e66322fbdfb045ba1ea5319d (patch) | |
tree | e4b50f63778529e5870ed9f6b83a949929214e2c | |
parent | 20aa135ad87231694ead2fe65a3124b719b8fc4d (diff) | |
download | tangerine-wallet-browser-4b63ec8f1daaba11e66322fbdfb045ba1ea5319d.tar tangerine-wallet-browser-4b63ec8f1daaba11e66322fbdfb045ba1ea5319d.tar.gz tangerine-wallet-browser-4b63ec8f1daaba11e66322fbdfb045ba1ea5319d.tar.bz2 tangerine-wallet-browser-4b63ec8f1daaba11e66322fbdfb045ba1ea5319d.tar.lz tangerine-wallet-browser-4b63ec8f1daaba11e66322fbdfb045ba1ea5319d.tar.xz tangerine-wallet-browser-4b63ec8f1daaba11e66322fbdfb045ba1ea5319d.tar.zst tangerine-wallet-browser-4b63ec8f1daaba11e66322fbdfb045ba1ea5319d.zip |
Test for failure of the async methods.
-rw-r--r-- | test/unit/metamask-controller-test.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/test/unit/metamask-controller-test.js b/test/unit/metamask-controller-test.js index fd420a70f..873b8d17d 100644 --- a/test/unit/metamask-controller-test.js +++ b/test/unit/metamask-controller-test.js @@ -39,17 +39,19 @@ describe('MetaMaskController', function () { beforeEach(function () { sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain') + sinon.spy(metamaskController.keyringController, 'createNewVaultAndRestore') }) afterEach(function () { metamaskController.keyringController.createNewVaultAndKeychain.restore() + metamaskController.keyringController.createNewVaultAndRestore.restore() }) describe('#createNewVaultAndKeychain', function () { it('can only create new vault on keyringController once', async function () { - const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity') + const password = 'a-fake-password' const first = await metamaskController.createNewVaultAndKeychain(password) @@ -60,6 +62,22 @@ describe('MetaMaskController', function () { 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) + }) + }) }) }) - |