Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / components / containers / forward / OutgoingForwardTable.spec.tsx
blob55878fa8bb69ae64f21981df933f41ce528a9b31
1 import { useAddressesKeys } from '@proton/account/addressKeys/hooks';
2 import { useAddresses } from '@proton/account/addresses/hooks';
3 import { renderWithProviders } from '@proton/components/containers/contacts/tests/render';
4 import type { Address, UserModel } from '@proton/shared/lib/interfaces';
5 import { ForwardingState, ForwardingType } from '@proton/shared/lib/interfaces';
6 import {
7     applyHOCs,
8     mockUseUser,
9     withApi,
10     withAuthentication,
11     withCache,
12     withConfig,
13     withEventManager,
14     withNotifications,
15 } from '@proton/testing';
17 import OutgoingForwardTable from './OutgoingForwardTable';
19 const OutgoingForwardTableContext = applyHOCs(
20     withApi(),
21     withEventManager(),
22     withCache(),
23     withNotifications(),
24     withConfig(),
25     withAuthentication()
26 )(OutgoingForwardTable);
28 jest.mock('@proton/account/addresses/hooks');
29 const mockUseAddresses = useAddresses as jest.MockedFunction<any>;
31 jest.mock('@proton/account/addressKeys/hooks');
32 const mockUserAddressesKeys = useAddressesKeys as jest.MockedFunction<any>;
34 describe('OutgoingForwardTable', () => {
35     beforeEach(() => {
36         const mockAddresses = [{ ID: 'AddressID' } as Address];
37         const mockAddressesKeys = [{}];
38         mockUseUser();
39         mockUseAddresses.mockReturnValue([mockAddresses, false]);
40         mockUserAddressesKeys.mockReturnValue(mockAddressesKeys);
41     });
43     const setup = () => {
44         const addresses = [
45             {
46                 ID: 'addressID',
47                 Email: 'forwarderEmail',
48             },
49         ] as Address[];
50         const chainedEmails = [''];
51         const user = {} as UserModel;
52         const forwardings = [
53             {
54                 ID: 'id',
55                 ForwarderAddressID: 'addressID',
56                 ForwardeeEmail: 'forwardeeEmail',
57                 State: ForwardingState.Active,
58                 CreateTime: 0,
59                 Type: ForwardingType.InternalEncrypted,
60                 Filter: null,
61             },
62         ];
63         const utils = renderWithProviders(
64             <OutgoingForwardTableContext
65                 user={user}
66                 forwardings={forwardings}
67                 addresses={addresses}
68                 chainedEmails={chainedEmails}
69             />
70         );
71         return { ...utils };
72     };
73     describe('when we display outgoing address forwarding', () => {
74         it('should show forwarder email address', () => {
75             const { getByText } = setup();
76             expect(getByText('forwarderEmail')).toBeInTheDocument();
77         });
79         it('should show forwardee email address', () => {
80             const { getByText } = setup();
81             expect(getByText('forwardeeEmail')).toBeInTheDocument();
82         });
83     });
84 });