This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix_merge_conflicts_imagings_meds
- Loading branch information
Showing
135 changed files
with
5,545 additions
and
1,849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { mount } from 'enzyme' | ||
import React from 'react' | ||
import { Provider } from 'react-redux' | ||
import { MemoryRouter } from 'react-router-dom' | ||
import createMockStore from 'redux-mock-store' | ||
import thunk from 'redux-thunk' | ||
|
||
import Imagings from '../../imagings/Imagings' | ||
import NewImagingRequest from '../../imagings/requests/NewImagingRequest' | ||
import ImagingRepository from '../../shared/db/ImagingRepository' | ||
import PatientRepository from '../../shared/db/PatientRepository' | ||
import Imaging from '../../shared/model/Imaging' | ||
import Patient from '../../shared/model/Patient' | ||
import Permissions from '../../shared/model/Permissions' | ||
import { RootState } from '../../shared/store' | ||
|
||
const mockStore = createMockStore<RootState, any>([thunk]) | ||
|
||
describe('Imagings', () => { | ||
jest.spyOn(ImagingRepository, 'findAll').mockResolvedValue([]) | ||
jest | ||
.spyOn(ImagingRepository, 'find') | ||
.mockResolvedValue({ id: '1234', requestedOn: new Date().toISOString() } as Imaging) | ||
jest | ||
.spyOn(PatientRepository, 'find') | ||
.mockResolvedValue({ id: '12345', fullName: 'test test' } as Patient) | ||
|
||
describe('routing', () => { | ||
describe('/imaging/new', () => { | ||
it('should render the new imaging request screen when /imaging/new is accessed', () => { | ||
const store = mockStore({ | ||
title: 'test', | ||
user: { permissions: [Permissions.RequestImaging] }, | ||
breadcrumbs: { breadcrumbs: [] }, | ||
components: { sidebarCollapsed: false }, | ||
imaging: { | ||
imaging: { id: 'imagingId', patient: 'patient' } as Imaging, | ||
patient: { id: 'patientId', fullName: 'some name' }, | ||
error: {}, | ||
}, | ||
} as any) | ||
|
||
const wrapper = mount( | ||
<Provider store={store}> | ||
<MemoryRouter initialEntries={['/imaging/new']}> | ||
<Imagings /> | ||
</MemoryRouter> | ||
</Provider>, | ||
) | ||
|
||
expect(wrapper.find(NewImagingRequest)).toHaveLength(1) | ||
}) | ||
|
||
it('should not navigate to /imagings/new if the user does not have RequestLab permissions', () => { | ||
const store = mockStore({ | ||
title: 'test', | ||
user: { permissions: [] }, | ||
breadcrumbs: { breadcrumbs: [] }, | ||
components: { sidebarCollapsed: false }, | ||
} as any) | ||
|
||
const wrapper = mount( | ||
<Provider store={store}> | ||
<MemoryRouter initialEntries={['/imagings/new']}> | ||
<Imagings /> | ||
</MemoryRouter> | ||
</Provider>, | ||
) | ||
|
||
expect(wrapper.find(NewImagingRequest)).toHaveLength(0) | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.