From ad02d60307666273a9dfa98ff2bc358cb9d5b23e Mon Sep 17 00:00:00 2001 From: codyarose Date: Sun, 27 Dec 2020 22:29:59 -0600 Subject: [PATCH 1/2] Convert ViewCareGoals.test.tsx to RTL --- .../care-goals/ViewCareGoals.test.tsx | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx b/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx index a80f7a7671..6c126b0b72 100644 --- a/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx +++ b/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx @@ -1,42 +1,40 @@ -import { mount, ReactWrapper } from 'enzyme' +import { render, waitFor } from '@testing-library/react' import { createMemoryHistory } from 'history' import React from 'react' -import { act } from 'react-dom/test-utils' import { Route, Router } from 'react-router-dom' -import CareGoalTable from '../../../patients/care-goals/CareGoalTable' import ViewCareGoals from '../../../patients/care-goals/ViewCareGoals' import PatientRepository from '../../../shared/db/PatientRepository' import CareGoal from '../../../shared/model/CareGoal' import Patient from '../../../shared/model/Patient' describe('View Care Goals', () => { - const patient = { id: '123', careGoals: [] as CareGoal[] } as Patient + const careGoal = { + id: 'abc', + status: 'accepted', + startDate: new Date().toISOString(), + dueDate: new Date().toISOString(), + } as CareGoal + const patient = { id: '123', careGoals: [careGoal] as CareGoal[] } as Patient const setup = async () => { jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient) const history = createMemoryHistory() history.push(`/patients/${patient.id}/care-goals`) - let wrapper: any - await act(async () => { - wrapper = await mount( - - - - - , - ) - }) - - return { wrapper: wrapper as ReactWrapper } + return render( + + + + + , + ) } - it('should render a care goals table with the patient id', async () => { - const { wrapper } = await setup() - - expect(wrapper.exists(CareGoalTable)).toBeTruthy() - const careGoalTable = wrapper.find(CareGoalTable) - expect(careGoalTable.prop('patientId')).toEqual(patient.id) + it('should render a care goals table', async () => { + const { container } = await setup() + await waitFor(() => { + expect(container.querySelector('table')).toBeInTheDocument() + }) }) }) From 617067f58ed676e7d952473be78c41000f3bc49f Mon Sep 17 00:00:00 2001 From: codyarose Date: Sun, 27 Dec 2020 22:34:35 -0600 Subject: [PATCH 2/2] Convert ViewCareGoals.test.tsx to RTL --- src/__tests__/patients/care-goals/ViewCareGoals.test.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx b/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx index 6c126b0b72..078cd72e6e 100644 --- a/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx +++ b/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx @@ -17,6 +17,7 @@ describe('View Care Goals', () => { } as CareGoal const patient = { id: '123', careGoals: [careGoal] as CareGoal[] } as Patient const setup = async () => { + jest.resetAllMocks() jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient) const history = createMemoryHistory()