diff --git a/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx b/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx index a80f7a7671..078cd72e6e 100644 --- a/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx +++ b/src/__tests__/patients/care-goals/ViewCareGoals.test.tsx @@ -1,42 +1,41 @@ -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.resetAllMocks() 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() + }) }) })