Merge branch 'INDA-330-pii-update' into 'main'
[ProtonMail-WebClient.git] / packages / testing / lib / mockUseSubscription.ts
blob52c6f79d743c831bcc8fa8b855f9e4e8fbba41f2
1 import * as useSubscriptionModule from '@proton/account/subscription/hooks';
2 import type { SubscriptionModel } from '@proton/shared/lib/interfaces';
4 import { buildSubscription } from '../builders';
6 export const mockUseSubscription = (value: [Partial<SubscriptionModel>?, boolean?] = []) => {
7     const [subscription, cached = false] = value;
8     const mockedUseSubscription = jest.spyOn(useSubscriptionModule, 'useSubscription');
9     mockedUseSubscription.mockReturnValue([buildSubscription(subscription), Boolean(cached)]);
10     return mockedUseSubscription;