From 492cb37c593f94ad17cce4a26fa527990b1c9639 Mon Sep 17 00:00:00 2001 From: oliv37 Date: Mon, 17 Feb 2020 21:37:59 +0100 Subject: [PATCH] feat(breadcrumb): use reduxPatient instead of patient for breadcrumbs --- src/__tests__/HospitalRun.test.tsx | 26 ++++++++++++++++++-------- src/patients/edit/EditPatient.tsx | 4 ++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/__tests__/HospitalRun.test.tsx b/src/__tests__/HospitalRun.test.tsx index 5886ad7c3b..bbfec06db1 100644 --- a/src/__tests__/HospitalRun.test.tsx +++ b/src/__tests__/HospitalRun.test.tsx @@ -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' @@ -76,15 +78,15 @@ describe('HospitalRun', () => { mockedPatientRepository.find.mockResolvedValue(patient) + const store = mockStore({ + title: 'test', + user: { permissions: [Permissions.WritePatients, Permissions.ReadPatients] }, + patient: { patient }, + breadcrumbs: { breadcrumbs: [] }, + }) + const wrapper = mount( - + @@ -92,6 +94,14 @@ describe('HospitalRun', () => { ) 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', () => { diff --git a/src/patients/edit/EditPatient.tsx b/src/patients/edit/EditPatient.tsx index f6f2e455ac..f75a7f5c4c 100644 --- a/src/patients/edit/EditPatient.tsx +++ b/src/patients/edit/EditPatient.tsx @@ -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)