diff options
author | Csaba Solya <csaba.solya@gmail.com> | 2018-03-04 15:57:55 +0800 |
---|---|---|
committer | Csaba Solya <csaba.solya@gmail.com> | 2018-03-04 15:57:55 +0800 |
commit | 8fde208f0b1da39ccd63b5f256902786e73e9368 (patch) | |
tree | dcd82738cd16dabcd4a414949cda11e64c299b98 /test/unit | |
parent | f7d4a1080df6d1c8ea5f68f88b01caea065b5e92 (diff) | |
download | tangerine-wallet-browser-8fde208f0b1da39ccd63b5f256902786e73e9368.tar tangerine-wallet-browser-8fde208f0b1da39ccd63b5f256902786e73e9368.tar.gz tangerine-wallet-browser-8fde208f0b1da39ccd63b5f256902786e73e9368.tar.bz2 tangerine-wallet-browser-8fde208f0b1da39ccd63b5f256902786e73e9368.tar.lz tangerine-wallet-browser-8fde208f0b1da39ccd63b5f256902786e73e9368.tar.xz tangerine-wallet-browser-8fde208f0b1da39ccd63b5f256902786e73e9368.tar.zst tangerine-wallet-browser-8fde208f0b1da39ccd63b5f256902786e73e9368.zip |
move more test code to beforeEach
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/seed-phrase-verifier-test.js | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/test/unit/seed-phrase-verifier-test.js b/test/unit/seed-phrase-verifier-test.js index 654fb5994..4e314806b 100644 --- a/test/unit/seed-phrase-verifier-test.js +++ b/test/unit/seed-phrase-verifier-test.js @@ -13,20 +13,23 @@ describe('SeedPhraseVerifier', function () { let hdKeyTree = 'HD Key Tree' let keyringController - beforeEach(function () { + let vault + let primaryKeyring + + beforeEach(async function () { keyringController = new KeyringController({ initState: clone(firstTimeState), encryptor: mockEncryptor, }) assert(keyringController) + + vault = await keyringController.createNewVaultAndKeychain(password) + primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] }) it('should be able to verify created account with seed words', async function () { - let vault = await keyringController.createNewVaultAndKeychain(password) - let primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] - let createdAccounts = await primaryKeyring.getAccounts() assert.equal(createdAccounts.length, 1) @@ -39,11 +42,9 @@ describe('SeedPhraseVerifier', function () { it('should be able to verify created account (upper case) with seed words', async function () { - let vault = await keyringController.createNewVaultAndKeychain(password) - let primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] - let createdAccounts = await primaryKeyring.getAccounts() assert.equal(createdAccounts.length, 1) + let upperCaseAccounts = [createdAccounts[0].toUpperCase()] let serialized = await primaryKeyring.serialize() @@ -55,9 +56,6 @@ describe('SeedPhraseVerifier', function () { it('should be able to verify created account (lower case) with seed words', async function () { - let vault = await keyringController.createNewVaultAndKeychain(password) - let primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] - let createdAccounts = await primaryKeyring.getAccounts() assert.equal(createdAccounts.length, 1) let lowerCaseAccounts = [createdAccounts[0].toLowerCase()] @@ -71,9 +69,6 @@ describe('SeedPhraseVerifier', function () { it('should return error with good but different seed words', async function () { - let vault = await keyringController.createNewVaultAndKeychain(password) - let primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] - let createdAccounts = await primaryKeyring.getAccounts() assert.equal(createdAccounts.length, 1) @@ -90,9 +85,6 @@ describe('SeedPhraseVerifier', function () { it('should return error with undefined existing accounts', async function () { - let vault = await keyringController.createNewVaultAndKeychain(password) - let primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] - let createdAccounts = await primaryKeyring.getAccounts() assert.equal(createdAccounts.length, 1) @@ -109,9 +101,6 @@ describe('SeedPhraseVerifier', function () { it('should return error with empty accounts array', async function () { - let vault = await keyringController.createNewVaultAndKeychain(password) - let primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] - let createdAccounts = await primaryKeyring.getAccounts() assert.equal(createdAccounts.length, 1) @@ -128,10 +117,6 @@ describe('SeedPhraseVerifier', function () { it('should be able to verify more than one created account with seed words', async function () { - let vault = await keyringController.createNewVaultAndKeychain(password) - - let primaryKeyring = keyringController.getKeyringsByType(hdKeyTree)[0] - const keyState = await keyringController.addNewAccount(primaryKeyring) const keyState2 = await keyringController.addNewAccount(primaryKeyring) |