Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / components / containers / security / PromptPinToggle.spec.tsx
blob279647fa5ea038184b5c603aa74c1340d2961a66
1 import { fireEvent, render } from '@testing-library/react';
3 import { updatePromptPin } from '@proton/shared/lib/api/mailSettings';
4 import {
5     applyHOCs,
6     mockUseApi,
7     mockUseEventManager,
8     mockUseMailSettings,
9     mockUseNotifications,
10     withApi,
11     withEventManager,
12     withNotifications,
13 } from '@proton/testing';
15 import PromptPinToggle from './PromptPinToggle';
17 const PromptPinToggleContext = applyHOCs(withApi(), withEventManager(), withNotifications())(PromptPinToggle);
19 describe('PromptPinToggle', () => {
20     let mockedApi: jest.Mock;
21     let mockedCall: jest.Mock;
23     beforeEach(() => {
24         mockedApi = jest.fn();
25         mockedCall = jest.fn();
27         mockUseApi(mockedApi);
28         mockUseEventManager({ call: mockedCall });
30         mockUseMailSettings();
31         mockUseNotifications();
32     });
34     const setup = () => {
35         const utils = render(<PromptPinToggleContext />);
36         return {
37             ...utils,
38         };
39     };
41     describe('when we toggle the component', () => {
42         it('should call the API', () => {
43             const { getByRole } = setup();
44             const toggle = getByRole('checkbox');
45             fireEvent.click(toggle);
46             expect(mockedApi).toHaveBeenCalledWith(updatePromptPin(1));
47         });
48     });
49 });