fix: Split AccountStorage and ForgotPasswordStorage (expiring now)

This commit is contained in:
Thomas Dupont
2022-02-09 13:26:42 +01:00
committed by GitHub
parent 90a6460c8d
commit d067165b68
5 changed files with 54 additions and 7 deletions

View File

@@ -3,10 +3,12 @@ import type {
EmailPasswordData,
} from '../../../../../../src/identity/interaction/email-password/storage/BaseAccountStore';
import { BaseAccountStore } from '../../../../../../src/identity/interaction/email-password/storage/BaseAccountStore';
import type { ExpiringStorage } from '../../../../../../src/storage/keyvalue/ExpiringStorage';
import type { KeyValueStorage } from '../../../../../../src/storage/keyvalue/KeyValueStorage';
describe('A BaseAccountStore', (): void => {
let storage: KeyValueStorage<string, EmailPasswordData>;
let forgotPasswordStorage: ExpiringStorage<string, EmailPasswordData>;
const saltRounds = 11;
let store: BaseAccountStore;
const email = 'test@test.com';
@@ -22,7 +24,13 @@ describe('A BaseAccountStore', (): void => {
delete: jest.fn((id: string): any => map.delete(id)),
} as any;
store = new BaseAccountStore(storage, saltRounds);
forgotPasswordStorage = {
get: jest.fn((id: string): any => map.get(id)),
set: jest.fn((id: string, value: any): any => map.set(id, value)),
delete: jest.fn((id: string): any => map.delete(id)),
} as any;
store = new BaseAccountStore(storage, forgotPasswordStorage, saltRounds);
});
it('can create accounts.', async(): Promise<void> => {