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

Commit

Permalink
Merge pull request #1822 from igeagonz/new-patient-message-fix
Browse files Browse the repository at this point in the history
fix(patient-slice.ts): conditionally render family name and suffix
  • Loading branch information
matteovivona committed Feb 13, 2020
2 parents e69de57 + 3bdd62d commit d5dacd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
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

1 comment on commit d5dacd6

@vercel
Copy link

@vercel vercel bot commented on d5dacd6 Feb 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.