Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / components / containers / forward / IncomingForwardTable.spec.tsx
blob9f94d78205c6a1282010bb45e0e9f3dacfafd364
1 import { useUser } from '@proton/account/user/hooks';
2 import { renderWithProviders } from '@proton/components/containers/contacts/tests/render';
3 import type { Address } from '@proton/shared/lib/interfaces';
4 import { ForwardingState, ForwardingType } from '@proton/shared/lib/interfaces';
5 import {
6     applyHOCs,
7     withApi,
8     withAuthentication,
9     withCache,
10     withConfig,
11     withEventManager,
12     withNotifications,
13 } from '@proton/testing';
15 import IncomingForwardTable from './IncomingForwardTable';
17 jest.mock('@proton/account/user/hooks');
18 const mockedUseUser = useUser as jest.MockedFunction<typeof useUser>;
19 mockedUseUser.mockReturnValue([{}] as any);
21 const IncomingForwardTableContext = applyHOCs(
22     withApi(),
23     withEventManager(),
24     withCache(),
25     withNotifications(),
26     withConfig(),
27     withAuthentication()
28 )(IncomingForwardTable);
30 describe('IncomingForwardTable', () => {
31     const setup = () => {
32         const addresses = [
33             {
34                 ID: 'addressID',
35                 Email: 'forwardeeEmail',
36             },
37         ] as Address[];
38         const chainedEmails = [''];
39         const forwardings = [
40             {
41                 ID: 'id',
42                 ForwardeeAddressID: 'addressID',
43                 ForwarderEmail: 'forwarderEmail',
44                 CreateTime: 0,
45                 Type: ForwardingType.InternalEncrypted,
46                 State: ForwardingState.Active,
47                 Filter: null,
48             },
49         ];
51         const utils = renderWithProviders(
52             <IncomingForwardTableContext
53                 forwardings={forwardings}
54                 addresses={addresses}
55                 chainedEmails={chainedEmails}
56             />
57         );
58         return { ...utils };
59     };
60     describe('when we display incoming address forwarding', () => {
61         it('should show forwarder email address', () => {
62             const { getByText } = setup();
63             expect(getByText('forwarderEmail')).toBeInTheDocument();
64         });
66         it('should show forwardee email address', () => {
67             const { getByText } = setup();
68             expect(getByText('forwardeeEmail')).toBeInTheDocument();
69         });
70     });
71 });