Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
fix(patient): appointments list tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oizuldan committed Apr 7, 2020
1 parent 1704ccb commit af66ec6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/__tests__/patients/appointments/NewAppointment.test.tsx
Expand Up @@ -5,7 +5,6 @@ import { createMemoryHistory } from 'history'
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import Patient from 'model/Patient'
import Permissions from 'model/Permissions'
import { Router } from 'react-router'
import { Provider } from 'react-redux'
import AppointmentsList from 'patients/appointments/AppointmentsList'
Expand All @@ -16,14 +15,25 @@ import PatientRepository from 'clients/db/PatientRepository'
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) => {
store = mockStore({ patient })
const setup = (patient = expectedPatient, appointments = expectedAppointments) => {
store = mockStore({ patient, appointments: { appointments } })
const wrapper = mount(
<Router history={history}>
<Provider store={store}>
Expand All @@ -45,7 +55,7 @@ describe('AppointmentsList', () => {
it('should render a new appointment button', () => {
const wrapper = setup()

const addNewAppointmentButton = wrapper.find(components.Button)
const addNewAppointmentButton = wrapper.find(components.Button).at(0)
expect(addNewAppointmentButton).toHaveLength(1)
expect(addNewAppointmentButton.text().trim()).toEqual('scheduling.appointments.new')
})
Expand All @@ -54,7 +64,10 @@ describe('AppointmentsList', () => {
const wrapper = setup()

act(() => {
wrapper.find(components.Button).prop('onClick')()
wrapper
.find(components.Button)
.at(0)
.prop('onClick')()
})
wrapper.update()

Expand Down

0 comments on commit af66ec6

Please sign in to comment.