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

Commit

Permalink
fix(patients): add test for displaying No Related Persons warning
Browse files Browse the repository at this point in the history
  • Loading branch information
archwheeler committed Feb 8, 2020
1 parent 5f2e055 commit da6bdb1
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/__tests__/patients/related-persons/RelatedPersons.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Router } from 'react-router'
import { createMemoryHistory } from 'history'
import { mount, ReactWrapper } from 'enzyme'
import RelatedPersonTab from 'patients/related-persons/RelatedPersonTab'
import { Button, List, ListItem } from '@hospitalrun/components'
import { Button, List, ListItem, Alert } from '@hospitalrun/components'
import NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal'
import { act } from '@testing-library/react'
import PatientRepository from 'clients/db/PatientRepository'
Expand Down Expand Up @@ -196,4 +196,39 @@ describe('Related Persons Tab', () => {
expect(history.location.pathname).toEqual('/patients/123001')
})
})

describe('EmptyList', () => {
const patient = {
id: '123',
rev: '123',
} as Patient

const user = {
permissions: [Permissions.WritePatients, Permissions.ReadPatients],
}

beforeEach(async () => {
jest.spyOn(PatientRepository, 'find')
mocked(PatientRepository.find).mockResolvedValue({
fullName: 'test test',
id: '123001',
} as Patient)

await act(async () => {
wrapper = await mount(
<Router history={history}>
<Provider store={mockStore({ patient, user })}>
<RelatedPersonTab patient={patient} />
</Provider>
</Router>,
)
})
wrapper.update()
})

it('should display a warning if patient has no related persons', () => {
const warning = wrapper.find(Alert)
expect(warning).toBeDefined()
})
})
})

0 comments on commit da6bdb1

Please sign in to comment.