Skip to content

Commit 1addbf6

Browse files
committed
update tests
1 parent 9c1c6cf commit 1addbf6

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

packages/keyring-controller/src/KeyringController.test.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ describe('KeyringController', () => {
425425
expect(controller.state).not.toBe(initialState);
426426
expect(controller.state.vault).toBeDefined();
427427
expect(controller.state.vault).toStrictEqual(initialVault);
428-
expect(controller.state.encryptionKey).toBeUndefined();
429-
expect(controller.state.encryptionSalt).toBeUndefined();
430428
},
431429
);
432430
});
@@ -573,6 +571,19 @@ describe('KeyringController', () => {
573571
},
574572
);
575573
});
574+
575+
!cacheEncryptionKey &&
576+
it('should not set encryptionKey and encryptionSalt in state', async () => {
577+
await withController(
578+
{ skipVaultCreation: true },
579+
async ({ controller }) => {
580+
await controller.createNewVaultAndKeychain(password);
581+
582+
expect(controller.state).not.toHaveProperty('encryptionKey');
583+
expect(controller.state).not.toHaveProperty('encryptionSalt');
584+
},
585+
);
586+
});
576587
});
577588

578589
describe('when there is an existing vault', () => {
@@ -597,11 +608,8 @@ describe('KeyringController', () => {
597608
},
598609
);
599610
});
600-
601611
cacheEncryptionKey &&
602-
// TODO: Re-enable this after we properly clear the key and salt from state upon lock
603-
// eslint-disable-next-line jest/no-disabled-tests
604-
it.skip('should set encryptionKey and encryptionSalt in state', async () => {
612+
it('should set encryptionKey and encryptionSalt in state', async () => {
605613
await withController(
606614
{ cacheEncryptionKey },
607615
async ({ controller }) => {
@@ -616,6 +624,17 @@ describe('KeyringController', () => {
616624
},
617625
);
618626
});
627+
!cacheEncryptionKey &&
628+
it('should not set encryptionKey and encryptionSalt in state', async () => {
629+
await withController(
630+
{ skipVaultCreation: false, cacheEncryptionKey },
631+
async ({ controller }) => {
632+
await controller.createNewVaultAndKeychain(password);
633+
expect(controller.state).not.toHaveProperty('encryptionKey');
634+
expect(controller.state).not.toHaveProperty('encryptionSalt');
635+
},
636+
);
637+
});
619638
});
620639
}),
621640
);
@@ -631,8 +650,8 @@ describe('KeyringController', () => {
631650

632651
expect(controller.isUnlocked()).toBe(false);
633652
expect(controller.state.isUnlocked).toBe(false);
634-
expect(controller.state.encryptionKey).toBeUndefined();
635-
expect(controller.state.encryptionSalt).toBeUndefined();
653+
expect(controller.state).not.toHaveProperty('encryptionKey');
654+
expect(controller.state).not.toHaveProperty('encryptionSalt');
636655
});
637656
});
638657

0 commit comments

Comments
 (0)