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

Commit

Permalink
feat(breadcrumb): use reduxPatient instead of patient for breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
oliv37 committed Feb 17, 2020
1 parent 4dc8a26 commit 492cb37
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
26 changes: 18 additions & 8 deletions src/__tests__/HospitalRun.test.tsx
Expand Up @@ -7,10 +7,12 @@ import { mocked } from 'ts-jest/utils'
import thunk from 'redux-thunk'
import configureMockStore from 'redux-mock-store'
import { Toaster } from '@hospitalrun/components'

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 { addBreadcrumbs } from 'breadcrumbs/breadcrumbs-slice'
import NewPatient from '../patients/new/NewPatient'
import EditPatient from '../patients/edit/EditPatient'
import ViewPatient from '../patients/view/ViewPatient'
Expand Down Expand Up @@ -76,22 +78,30 @@ describe('HospitalRun', () => {

mockedPatientRepository.find.mockResolvedValue(patient)

const store = mockStore({
title: 'test',
user: { permissions: [Permissions.WritePatients, Permissions.ReadPatients] },
patient: { patient },
breadcrumbs: { breadcrumbs: [] },
})

const wrapper = mount(
<Provider
store={mockStore({
title: 'test',
user: { permissions: [Permissions.WritePatients, Permissions.ReadPatients] },
patient: { patient: {} as Patient },
breadcrumbs: { breadcrumbs: [] },
})}
>
<Provider store={store}>
<MemoryRouter initialEntries={['/patients/edit/123']}>
<HospitalRun />
</MemoryRouter>
</Provider>,
)

expect(wrapper.find(EditPatient)).toHaveLength(1)

expect(store.getActions()).toContainEqual(
addBreadcrumbs([
{ i18nKey: 'patients.label', location: '/patients' },
{ text: 'test test test', location: `/patients/${patient.id}` },
{ i18nKey: 'patients.editPatient', location: `/patients/${patient.id}/edit` },
]),
)
})

it('should render the Dashboard when the user does not have read patient privileges', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/patients/edit/EditPatient.tsx
Expand Up @@ -37,8 +37,8 @@ const EditPatient = () => {

const breadcrumbs = [
{ i18nKey: 'patients.label', location: '/patients' },
{ text: getPatientFullName(patient), location: `/patients/${patient.id}` },
{ i18nKey: 'patients.editPatient', location: `/patients/${patient.id}/edit` },
{ text: getPatientFullName(reduxPatient), location: `/patients/${reduxPatient.id}` },
{ i18nKey: 'patients.editPatient', location: `/patients/${reduxPatient.id}/edit` },
]
useAddBreadcrumbs(breadcrumbs)

Expand Down

0 comments on commit 492cb37

Please sign in to comment.