1 import { renderHook } from '@testing-library/react-hooks';
3 import { useSubscription } from '@proton/account/subscription/hooks';
4 import { FREE_SUBSCRIPTION } from '@proton/payments';
6 import useMozillaCheck from './useMozillaCheck';
8 jest.mock('@proton/account/subscription/hooks');
10 it('should return false if subscription is still loading', () => {
11 jest.mocked(useSubscription).mockReturnValue([undefined as any, true]);
13 const { result } = renderHook(() => useMozillaCheck());
15 expect(result.current).toEqual([false, true]);
18 it('should return false if not managed by Mozilla', () => {
19 jest.mocked(useSubscription).mockReturnValue([{ isManagedByMozilla: false } as any, false]);
21 const { result } = renderHook(() => useMozillaCheck());
23 expect(result.current).toEqual([false, false]);
26 it('should return true if managed by Mozilla', () => {
27 jest.mocked(useSubscription).mockReturnValue([{ isManagedByMozilla: true } as any, false]);
29 const { result } = renderHook(() => useMozillaCheck());
31 expect(result.current).toEqual([true, false]);
34 it('should return false if subscription is free', () => {
35 jest.mocked(useSubscription).mockReturnValue([FREE_SUBSCRIPTION as any, false]);
37 const { result } = renderHook(() => useMozillaCheck());
39 expect(result.current).toEqual([false, false]);