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

fix(patient-slice.ts): conditionally render family name and suffix #1822

Merged
merged 8 commits into from
Feb 13, 2020
20 changes: 6 additions & 14 deletions src/__tests__/patients/patient-slice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,10 @@ describe('patients slice', () => {
it('should call the Toaster function with the correct data', async () => {
jest.spyOn(components, 'Toast')
const expectedPatientId = '12345'
const expectedGivenName = 'given'
const expectedFamilyName = 'family'
const expectedSuffix = 'suffix'
const expectedFullName = 'John Doe II'
const expectedPatient = {
id: expectedPatientId,
givenName: expectedGivenName,
familyName: expectedFamilyName,
suffix: expectedSuffix,
fullName: expectedFullName,
} as Patient
const mockedPatientRepository = mocked(PatientRepository, true)
mockedPatientRepository.save.mockResolvedValue(expectedPatient)
Expand All @@ -182,7 +178,7 @@ describe('patients slice', () => {
expect(mockedComponents.Toast).toHaveBeenCalledWith(
'success',
'Success!',
`patients.successfullyCreated ${expectedGivenName} ${expectedFamilyName} ${expectedSuffix}`,
`patients.successfullyCreated ${expectedFullName}`,
)
})
})
Expand Down Expand Up @@ -286,14 +282,10 @@ describe('patients slice', () => {
it('should call the Toaster function with the correct data', async () => {
jest.spyOn(components, 'Toast')
const expectedPatientId = '12345'
const expectedGivenName = 'given'
const expectedFamilyName = 'family'
const expectedSuffix = 'suffix'
const fullName = 'John Doe II'
const expectedPatient = {
id: expectedPatientId,
givenName: expectedGivenName,
familyName: expectedFamilyName,
suffix: expectedSuffix,
fullName,
} as Patient
const mockedPatientRepository = mocked(PatientRepository, true)
mockedPatientRepository.saveOrUpdate.mockResolvedValue(expectedPatient)
Expand All @@ -307,7 +299,7 @@ describe('patients slice', () => {
expect(mockedComponents.Toast).toHaveBeenCalledWith(
'success',
'Success!',
`patients.successfullyUpdated ${expectedGivenName} ${expectedFamilyName} ${expectedSuffix}`,
`patients.successfullyUpdated ${fullName}`,
)
})
})
Expand Down
8 changes: 2 additions & 6 deletions src/patients/patient-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export const createPatient = (patient: Patient, history: any): AppThunk => async
Toast(
'success',
il8n.t('Success!'),
`${il8n.t('patients.successfullyCreated')} ${patient.givenName} ${patient.familyName} ${
patient.suffix
}`,
`${il8n.t('patients.successfullyCreated')} ${patient.fullName}`,
)
}

Expand All @@ -81,9 +79,7 @@ export const updatePatient = (patient: Patient, history: any): AppThunk => async
Toast(
'success',
il8n.t('Success!'),
`${il8n.t('patients.successfullyUpdated')} ${patient.givenName} ${patient.familyName} ${
patient.suffix
}`,
`${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`,
)
}

Expand Down