This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1964 from oizuldan/master
feat(patient): add appointment button
- Loading branch information
Showing
3 changed files
with
112 additions
and
24 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/__tests__/patients/appointments/AppointmentsList.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import '../../../__mocks__/matchMediaMock' | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import { createMemoryHistory } from 'history' | ||
import configureMockStore from 'redux-mock-store' | ||
import thunk from 'redux-thunk' | ||
import Patient from 'model/Patient' | ||
import { Router } from 'react-router' | ||
import { Provider } from 'react-redux' | ||
import AppointmentsList from 'patients/appointments/AppointmentsList' | ||
import * as components from '@hospitalrun/components' | ||
import { act } from 'react-dom/test-utils' | ||
// import PatientRepository from 'clients/db/PatientRepository' # Lint warning: 'PatientRepository' is defined but never used | ||
|
||
const expectedPatient = { | ||
id: '123', | ||
} as Patient | ||
const expectedAppointments = [ | ||
{ | ||
id: '123', | ||
rev: '1', | ||
patientId: '1234', | ||
startDateTime: new Date().toISOString(), | ||
endDateTime: new Date().toISOString(), | ||
location: 'location', | ||
reason: 'reason', | ||
}, | ||
] | ||
|
||
const mockStore = configureMockStore([thunk]) | ||
const history = createMemoryHistory() | ||
|
||
let store: any | ||
|
||
const setup = (patient = expectedPatient, appointments = expectedAppointments) => { | ||
store = mockStore({ patient, appointments: { appointments } }) | ||
const wrapper = mount( | ||
<Router history={history}> | ||
<Provider store={store}> | ||
<AppointmentsList patientId={patient.id} /> | ||
</Provider> | ||
</Router>, | ||
) | ||
|
||
return wrapper | ||
} | ||
|
||
describe('AppointmentsList', () => { | ||
describe('add new appointment button', () => { | ||
it('should render a new appointment button', () => { | ||
const wrapper = setup() | ||
|
||
const addNewAppointmentButton = wrapper.find(components.Button).at(0) | ||
expect(addNewAppointmentButton).toHaveLength(1) | ||
expect(addNewAppointmentButton.text().trim()).toEqual('scheduling.appointments.new') | ||
}) | ||
|
||
it('should navigate to new appointment page', () => { | ||
const wrapper = setup() | ||
|
||
act(() => { | ||
wrapper.find(components.Button).at(0).prop('onClick')() | ||
}) | ||
wrapper.update() | ||
|
||
expect(history.location.pathname).toEqual('/appointments/new') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5d02d97
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: