Merge branch 'renovate/all-minor-patch' into 'main'
[ProtonMail-WebClient.git] / packages / testing / lib / vitest / mockUseAddresses.ts
blobb9cd937cd15bc6ec8742dd16eb4e339b31ddddaf
1 import * as useAddressesModule from '@proton/account/addresses/hooks';
2 import type { Address } from '@proton/shared/lib/interfaces';
4 export const mockUseAddresses = (value: [Address[]?, boolean?] = []) => {
5     const [addresses, cached = false] = value;
6     const mockedUseAddresses = vi.spyOn(useAddressesModule, 'useAddresses');
7     mockedUseAddresses.mockReturnValue([addresses ?? [], Boolean(cached)]);
8     return mockedUseAddresses;
9 };
11 export const mockUseGetAddresses = (value: Address[] = []) => {
12     const mockedUseAddresses = vi.spyOn(useAddressesModule, 'useGetAddresses');
13     mockedUseAddresses.mockReturnValue(vi.fn(async () => value ?? []));
14     return mockedUseAddresses;