-
Notifications
You must be signed in to change notification settings - Fork 227
/
flags-list.test.tsx
44 lines (36 loc) · 1.58 KB
/
flags-list.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from 'react';
import { render, screen } from '@testing-library/react';
import { mockPatient } from 'tools';
import { mockPatientFlags } from '__mocks__';
import { usePatientFlags } from './hooks/usePatientFlags';
import FlagsList from './flags-list.component';
const mockedUsePatientFlags = usePatientFlags as jest.Mock;
jest.mock('./hooks/usePatientFlags', () => {
const originalModule = jest.requireActual('./hooks/usePatientFlags');
return {
...originalModule,
usePatientFlags: jest.fn(),
};
});
it('renders an Edit form that enables users to toggle flags on or off', async () => {
mockedUsePatientFlags.mockReturnValue({
flags: mockPatientFlags,
isLoading: false,
error: null,
});
renderFlagsList();
const searchbox = screen.getByRole('searchbox', { name: /search for a flag/i });
const clearSearchInputButton = screen.getByRole('button', { name: /clear search input/i });
const discardButton = screen.getByRole('button', { name: /discard/i });
const saveButton = screen.getByRole('button', { name: /save & close/i });
expect(searchbox).toBeInTheDocument();
expect(clearSearchInputButton).toBeInTheDocument();
expect(discardButton).toBeInTheDocument();
expect(saveButton).toBeInTheDocument();
expect(screen.getByText(/future appointment/i)).toBeInTheDocument();
expect(screen.getByText(/needs follow up/i)).toBeInTheDocument();
expect(screen.getByText(/social/i)).toBeInTheDocument();
});
function renderFlagsList() {
return render(<FlagsList closeWorkspace={jest.fn()} patientUuid={mockPatient.id} promptBeforeClosing={jest.fn()} />);
}