Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / testing / lib / vitest / mockUseAddressKeys.ts
blobeeb0d0886e9f60115bd85c2e7450d73b18758bb6
1 import * as useAddressKeysModule from '@proton/account/addressKeys/hooks';
2 import type { Address, DecryptedAddressKey } from '@proton/shared/lib/interfaces';
4 export const mockUseAddressKeys = (value: [{ address: Address; keys: DecryptedAddressKey[] }[]?, boolean?] = []) => {
5     const [keys, cached = false] = value;
6     const mockedUseAddressKeys = vi.spyOn(useAddressKeysModule, 'useAddressesKeys');
7     mockedUseAddressKeys.mockReturnValue([keys ?? [], Boolean(cached)]);
8     return mockedUseAddressKeys;
9 };
11 export const mockUseGetAddressKeys = (value?: ReturnType<typeof useAddressKeysModule.useGetAddressKeys>) => {
12     const mockedUseGetAddressKeys = vi.spyOn(useAddressKeysModule, 'useGetAddressKeys');
13     mockedUseGetAddressKeys.mockReturnValue(value ?? vi.fn());
14     return mockedUseGetAddressKeys;