Remove payments API routing initialization
[ProtonMail-WebClient.git] / packages / components / containers / recovery / DailyEmailNotificationToggle.test.tsx
blob2ef02cd2fdd41bc40f99dc108168b4c0375adbae
1 import { fireEvent, render, waitFor } from '@testing-library/react';
3 import DailyEmailNotificationToggle from './DailyEmailNotificationToggle';
5 describe('DailyEmailNotificationToggle', () => {
6     describe('when annot enable', () => {
7         it('should have disabled attribute', () => {
8             const { container } = render(
9                 <DailyEmailNotificationToggle
10                     canEnable={false}
11                     isEnabled={false}
12                     onChange={jest.fn()}
13                     id="test-toggle"
14                 />
15             );
17             const input = container.querySelector('#test-toggle');
18             expect(input).toHaveAttribute('disabled', '');
19         });
20     });
22     describe('when can enable', () => {
23         it('should check checkbox if enabled', () => {
24             const { container } = render(
25                 <DailyEmailNotificationToggle canEnable={true} isEnabled={true} onChange={jest.fn()} id="test-toggle" />
26             );
28             const input = container.querySelector('#test-toggle');
29             expect(input).not.toHaveAttribute('disabled');
30             expect(input).toHaveAttribute('checked', '');
31         });
33         it('should emit onChange on click', async () => {
34             const mockOnChange = jest.fn();
35             const { container } = render(
36                 <DailyEmailNotificationToggle
37                     canEnable={true}
38                     isEnabled={true}
39                     onChange={mockOnChange}
40                     id="test-toggle"
41                 />
42             );
44             const input = container.querySelector('#test-toggle');
45             fireEvent.click(input as HTMLElement);
47             await waitFor(() => expect(mockOnChange).toHaveBeenCalledTimes(1));
48         });
49     });
50 });