diff --git a/src/__tests__/HospitalRun.test.tsx b/src/__tests__/HospitalRun.test.tsx
index 569e241c02..9cd65ce7e3 100644
--- a/src/__tests__/HospitalRun.test.tsx
+++ b/src/__tests__/HospitalRun.test.tsx
@@ -11,11 +11,14 @@ import { act } from 'react-dom/test-utils'
import Dashboard from 'dashboard/Dashboard'
import Appointments from 'scheduling/appointments/Appointments'
import NewAppointment from 'scheduling/appointments/new/NewAppointment'
+import EditAppointment from 'scheduling/appointments/edit/EditAppointment'
import NewPatient from '../patients/new/NewPatient'
import EditPatient from '../patients/edit/EditPatient'
import ViewPatient from '../patients/view/ViewPatient'
import PatientRepository from '../clients/db/PatientRepository'
+import AppointmentRepository from '../clients/db/AppointmentRepository'
import Patient from '../model/Patient'
+import Appointment from '../model/Appointment'
import HospitalRun from '../HospitalRun'
import Permissions from '../model/Permissions'
@@ -217,41 +220,110 @@ describe('HospitalRun', () => {
expect(wrapper.find(Dashboard)).toHaveLength(1)
})
})
- })
- describe('/appointments/new', () => {
- it('should render the new appointment screen when /appointments/new is accessed', async () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ describe('/appointments/new', () => {
+ it('should render the new appointment screen when /appointments/new is accessed', async () => {
+ const wrapper = mount(
+
+
+
+
+ ,
+ )
+
+ expect(wrapper.find(NewAppointment)).toHaveLength(1)
+ })
- expect(wrapper.find(NewAppointment)).toHaveLength(1)
+ it('should render the Dashboard when the user does not have read appointment privileges', () => {
+ const wrapper = mount(
+
+
+
+
+ ,
+ )
+
+ expect(wrapper.find(Dashboard)).toHaveLength(1)
+ })
})
- it('should render the Dashboard when the user does not have read appointment privileges', () => {
- const wrapper = mount(
-
-
-
-
- ,
- )
+ describe('/appointments/edit/:id', () => {
+ it('should render the edit appointment screen when /appointments/edit/:id is accessed', () => {
+ jest.spyOn(AppointmentRepository, 'find')
+ const mockedAppointmentRepository = mocked(AppointmentRepository, true)
+ const mockedPatientRepository = mocked(PatientRepository, true)
+ const appointment = {
+ id: '123',
+ patientId: '456',
+ } as Appointment
+
+ const patient = {
+ id: '456',
+ } as Patient
+
+ mockedAppointmentRepository.find.mockResolvedValue(appointment)
+ mockedPatientRepository.find.mockResolvedValue(patient)
+
+ const wrapper = mount(
+
+
+
+
+ ,
+ )
+
+ expect(wrapper.find(EditAppointment)).toHaveLength(1)
+ })
+
+ it('should render the Dashboard when the user does not have read appointment privileges', () => {
+ const wrapper = mount(
+
+
+
+
+ ,
+ )
+
+ expect(wrapper.find(Dashboard)).toHaveLength(1)
+ })
+
+ it('should render the Dashboard when the user does not have write appointment privileges', () => {
+ const wrapper = mount(
+
+
+
+
+ ,
+ )
- expect(wrapper.find(Dashboard)).toHaveLength(1)
+ expect(wrapper.find(Dashboard)).toHaveLength(1)
+ })
})
})