diff --git a/src/__tests__/patients/view/ViewPatient.test.tsx b/src/__tests__/patients/view/ViewPatient.test.tsx index 15bc7f1810..5b56f8df0b 100644 --- a/src/__tests__/patients/view/ViewPatient.test.tsx +++ b/src/__tests__/patients/view/ViewPatient.test.tsx @@ -5,7 +5,7 @@ import { mount } from 'enzyme' import { mocked } from 'ts-jest/utils' import { act } from 'react-dom/test-utils' import { Route, Router } from 'react-router-dom' -import { TabsHeader, Tab, Button } from '@hospitalrun/components' +import { TabsHeader, Tab } from '@hospitalrun/components' import configureMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import GeneralInformation from 'patients/GeneralInformation' diff --git a/src/__tests__/scheduling/appointments/Appointments.test.tsx b/src/__tests__/scheduling/appointments/Appointments.test.tsx index 4c3b73282e..8e6f49108d 100644 --- a/src/__tests__/scheduling/appointments/Appointments.test.tsx +++ b/src/__tests__/scheduling/appointments/Appointments.test.tsx @@ -62,7 +62,9 @@ describe('Appointments', () => { }) const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0] - expect((actualButtons[0] as any).props.children).toEqual('scheduling.appointments.new') + expect((actualButtons[0] as any).props.children).toEqual( + 'scheduling.appointments.newAppointment', + ) }) it('should render a calendar with the proper events', async () => { diff --git a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx index 6316dc2d30..85e475bb5a 100644 --- a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx @@ -15,6 +15,7 @@ import { Spinner } from '@hospitalrun/components' import AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm' import PatientRepository from 'clients/db/PatientRepository' import Patient from 'model/Patient' +import * as ButtonBarProvider from 'page-header/ButtonBarProvider' import * as titleUtil from '../../../../page-header/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' @@ -72,7 +73,7 @@ describe('View Appointment', () => { } beforeEach(() => { - jest.resetAllMocks() + jest.restoreAllMocks() }) it('should use the correct title', async () => { @@ -84,6 +85,17 @@ describe('View Appointment', () => { expect(titleUtil.default).toHaveBeenCalledWith('scheduling.appointments.viewAppointment') }) + it('should add a "Edit Appointment" button to the button tool bar', () => { + jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter') + const setButtonToolBarSpy = jest.fn() + mocked(ButtonBarProvider).useButtonToolbarSetter.mockReturnValue(setButtonToolBarSpy) + + setup(true) + + const actualButtons: React.ReactNode[] = setButtonToolBarSpy.mock.calls[0][0] + expect((actualButtons[0] as any).props.children).toEqual('actions.edit') + }) + it('should dispatch getAppointment if id is present', async () => { await act(async () => { await setup(true) diff --git a/src/patients/edit/EditPatient.tsx b/src/patients/edit/EditPatient.tsx index b47de7491c..5ce7b57957 100644 --- a/src/patients/edit/EditPatient.tsx +++ b/src/patients/edit/EditPatient.tsx @@ -86,10 +86,10 @@ const EditPatient = () => { />