diff --git a/src/__tests__/patients/search/ViewPatients.test.tsx b/src/__tests__/patients/search/ViewPatients.test.tsx index 0fac0e3b3e..b03a3a36e4 100644 --- a/src/__tests__/patients/search/ViewPatients.test.tsx +++ b/src/__tests__/patients/search/ViewPatients.test.tsx @@ -33,7 +33,7 @@ describe('Patients', () => { jest.spyOn(PatientRepository, 'search').mockResolvedValue([]) }) - it('should render the search patients component', async () => { + it('should render the search patients component', () => { setup() userEvent.type(screen.getByRole('textbox'), 'Jean Luc Picard') expect(screen.getByRole('textbox')).toHaveValue('Jean Luc Picard') diff --git a/src/__tests__/patients/search/ViewPatientsTable.test.tsx b/src/__tests__/patients/search/ViewPatientsTable.test.tsx index 47756e5606..1e22809e48 100644 --- a/src/__tests__/patients/search/ViewPatientsTable.test.tsx +++ b/src/__tests__/patients/search/ViewPatientsTable.test.tsx @@ -1,9 +1,4 @@ -import { - render as rtlRender, - screen, - waitFor, - waitForElementToBeRemoved, -} from '@testing-library/react' +import { screen, render, waitFor, waitForElementToBeRemoved } from '@testing-library/react' import format from 'date-fns/format' import React from 'react' @@ -13,13 +8,11 @@ import PatientRepository from '../../../shared/db/PatientRepository' import Patient from '../../../shared/model/Patient' describe('View Patients Table', () => { - const render = (expectedSearchRequest: PatientSearchRequest, expectedPatients: Patient[]) => { + const setup = (expectedSearchRequest: PatientSearchRequest, expectedPatients: Patient[]) => { jest.spyOn(PatientRepository, 'search').mockResolvedValueOnce(expectedPatients) jest.spyOn(PatientRepository, 'count').mockResolvedValueOnce(expectedPatients.length) - const results = rtlRender() - - return results + return render() } beforeEach(() => { @@ -28,14 +21,14 @@ describe('View Patients Table', () => { it('should search for patients given a search request', () => { const expectedSearchRequest = { queryString: 'someQueryString' } - render(expectedSearchRequest, []) + setup(expectedSearchRequest, []) expect(PatientRepository.search).toHaveBeenCalledTimes(1) expect(PatientRepository.search).toHaveBeenCalledWith(expectedSearchRequest.queryString) }) it('should display no patients exist if total patient count is 0', async () => { - const { container } = render({ queryString: '' }, []) + const { container } = setup({ queryString: '' }, []) await waitForElementToBeRemoved(container.querySelector('.css-0')) expect(screen.getByRole('heading', { name: /patients.noPatients/i })).toBeInTheDocument() }) @@ -51,7 +44,7 @@ describe('View Patients Table', () => { } as Patient const expectedPatients = [expectedPatient] - render({ queryString: '' }, expectedPatients) + setup({ queryString: '' }, expectedPatients) await waitFor(() => screen.getByText('familyName')) const cells = screen.getAllByRole('cell') diff --git a/src/__tests__/patients/view/ImportantPatientInfo.test.tsx b/src/__tests__/patients/view/ImportantPatientInfo.test.tsx index aa7b066b58..815effb7ff 100644 --- a/src/__tests__/patients/view/ImportantPatientInfo.test.tsx +++ b/src/__tests__/patients/view/ImportantPatientInfo.test.tsx @@ -52,7 +52,7 @@ describe('Important Patient Info Panel', () => { ], } as Patient - const setup = async (patient = expectedPatient, permissions: Permissions[]) => { + const setup = (patient = expectedPatient, permissions: Permissions[]) => { jest.resetAllMocks() jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient) history = createMemoryHistory() @@ -76,24 +76,24 @@ describe('Important Patient Info Panel', () => { } }) - it("should render patient's code", async () => { + it("should render patient's code", () => { setup(expectedPatient, []) expect(screen.getByText(expectedPatient.code)).toBeInTheDocument() }) - it("should render patient's sex", async () => { + it("should render patient's sex", () => { setup(expectedPatient, []) expect(screen.getByText(expectedPatient.sex)).toBeInTheDocument() }) - it("should render patient's dateOfDate", async () => { + it("should render patient's dateOfDate", () => { setup(expectedPatient, []) expect(screen.getAllByText(expectedPatient.dateOfBirth)[0]).toBeInTheDocument() }) }) describe('add new visit button', () => { - it('should render an add visit button if user has correct permissions', async () => { + it('should render an add visit button if user has correct permissions', () => { setup(expectedPatient, [Permissions.AddVisit]) expect(screen.getByRole('button', { name: /patient.visits.new/i })).toBeInTheDocument() }) @@ -115,14 +115,14 @@ describe('Important Patient Info Panel', () => { expect(await screen.findByRole('dialog')).not.toBeInTheDocument() }) - it('should not render new visit button if user does not have permissions', async () => { + it('should not render new visit button if user does not have permissions', () => { setup(expectedPatient, []) expect(screen.queryByRole('button', { name: /patient.visits.new/i })).not.toBeInTheDocument() }) }) describe('add new allergy button', () => { - it('should render an add allergy button if user has correct permissions', async () => { + it('should render an add allergy button if user has correct permissions', () => { setup(expectedPatient, [Permissions.AddAllergy]) expect(screen.getByRole('button', { name: /patient.allergies.new/i })).toBeInTheDocument() }) @@ -144,7 +144,7 @@ describe('Important Patient Info Panel', () => { expect(await screen.findByRole('dialog')).not.toBeInTheDocument() }) - it('should not render new allergy button if user does not have permissions', async () => { + it('should not render new allergy button if user does not have permissions', () => { setup(expectedPatient, []) expect( screen.queryByRole('button', { name: /patient.allergies.new/i }), @@ -153,7 +153,7 @@ describe('Important Patient Info Panel', () => { }) describe('add diagnoses button', () => { - it('should render an add diagnosis button if user has correct permissions', async () => { + it('should render an add diagnosis button if user has correct permissions', () => { setup(expectedPatient, [Permissions.AddDiagnosis]) expect(screen.getByRole('button', { name: /patient.diagnoses.new/i })).toBeInTheDocument() }) @@ -175,7 +175,7 @@ describe('Important Patient Info Panel', () => { expect(await screen.findByRole('dialog')).not.toBeInTheDocument() }) - it('should not render new diagnosis button if user does not have permissions', async () => { + it('should not render new diagnosis button if user does not have permissions', () => { setup(expectedPatient, []) expect( screen.queryByRole('button', { name: /patient.diagnoses.new/i }),