mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
move more test code to beforeEach
This commit is contained in:
parent
f7d4a1080d
commit
8fde208f0b
@ -13,20 +13,23 @@ describe('SeedPhraseVerifier', function () {
|
|||||||
let hdKeyTree = 'HD Key Tree'
|
let hdKeyTree = 'HD Key Tree'
|
||||||
|
|
||||||
let keyringController
|
let keyringController
|
||||||
beforeEach(function () {
|
let vault
|
||||||
|
let primaryKeyring
|
||||||
|
|
||||||
|
beforeEach(async function () {
|
||||||
keyringController = new KeyringController({
|
keyringController = new KeyringController({
|
||||||
initState: clone(firstTimeState),
|
initState: clone(firstTimeState),
|
||||||
encryptor: mockEncryptor,
|
encryptor: mockEncryptor,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert(keyringController)
|
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 () {
|
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()
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
assert.equal(createdAccounts.length, 1)
|
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 () {
|
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()
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
assert.equal(createdAccounts.length, 1)
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
let upperCaseAccounts = [createdAccounts[0].toUpperCase()]
|
let upperCaseAccounts = [createdAccounts[0].toUpperCase()]
|
||||||
|
|
||||||
let serialized = await primaryKeyring.serialize()
|
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 () {
|
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()
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
assert.equal(createdAccounts.length, 1)
|
assert.equal(createdAccounts.length, 1)
|
||||||
let lowerCaseAccounts = [createdAccounts[0].toLowerCase()]
|
let lowerCaseAccounts = [createdAccounts[0].toLowerCase()]
|
||||||
@ -71,9 +69,6 @@ describe('SeedPhraseVerifier', function () {
|
|||||||
|
|
||||||
it('should return error with good but different seed words', async 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()
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
assert.equal(createdAccounts.length, 1)
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
@ -90,9 +85,6 @@ describe('SeedPhraseVerifier', function () {
|
|||||||
|
|
||||||
it('should return error with undefined existing accounts', async 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()
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
assert.equal(createdAccounts.length, 1)
|
assert.equal(createdAccounts.length, 1)
|
||||||
|
|
||||||
@ -109,9 +101,6 @@ describe('SeedPhraseVerifier', function () {
|
|||||||
|
|
||||||
it('should return error with empty accounts array', async 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()
|
let createdAccounts = await primaryKeyring.getAccounts()
|
||||||
assert.equal(createdAccounts.length, 1)
|
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 () {
|
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 keyState = await keyringController.addNewAccount(primaryKeyring)
|
||||||
const keyState2 = await keyringController.addNewAccount(primaryKeyring)
|
const keyState2 = await keyringController.addNewAccount(primaryKeyring)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user