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 #14 from kcdraidgroup/juhanakristian
Browse files Browse the repository at this point in the history
Converts Imagings.test.tsx to RTL
  • Loading branch information
JacobMGEvans authored Dec 16, 2020
2 parents f9ec623 + be5265b commit 5228eab
Show file tree
Hide file tree
Showing 2 changed files with 317 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/__tests__/imagings/Imagings.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount, ReactWrapper } from 'enzyme'
import { render } from '@testing-library/react'
import React from 'react'
import { Provider } from 'react-redux'
import { MemoryRouter } from 'react-router-dom'
Expand Down Expand Up @@ -39,31 +39,29 @@ describe('Imagings', () => {
},
} as any)

const wrapper = mount(
return render(
<Provider store={store}>
<MemoryRouter initialEntries={['/imaging/new']}>
<TitleProvider>{isNew ? <NewImagingRequest /> : <Imagings />}</TitleProvider>
</MemoryRouter>
</Provider>,
)
wrapper.update()
return { wrapper: wrapper as ReactWrapper }
}

describe('routing', () => {
describe('/imaging/new', () => {
it('should render the new imaging request screen when /imaging/new is accessed', async () => {
const permissions: Permissions[] = [Permissions.RequestImaging]
const { wrapper } = setup(permissions, true)
const { container } = setup(permissions, true)

expect(wrapper.find(NewImagingRequest)).toHaveLength(1)
expect(container).toMatchSnapshot()
})

it('should not navigate to /imagings/new if the user does not have RequestImaging permissions', async () => {
const permissions: Permissions[] = []
const { wrapper } = setup(permissions)
const { container } = setup(permissions)

expect(wrapper.find(NewImagingRequest)).toHaveLength(0)
expect(container).toMatchInlineSnapshot(`<div />`)
})
})
})
Expand Down
311 changes: 311 additions & 0 deletions src/__tests__/imagings/__snapshots__/Imagings.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP


exports[`Imagings routing /imaging/new should render the new imaging request screen when /imaging/new is accessed 1`] = `
<div>
<form>
<div
class="row"
>
<div
class="col"
>
<div
class="form-group patient-typeahead"
>
<div>
<label
class="form-label"
for="patientTypeahead"
title="This is a required input"
>
imagings.imaging.patient
<i
style="color: red;"
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-asterisk fa-w-16 "
data-icon="asterisk"
data-prefix="fas"
focusable="false"
role="img"
style="height: 7px; vertical-align: top; margin-left: 2px;"
viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M478.21 334.093L336 256l142.21-78.093c11.795-6.477 15.961-21.384 9.232-33.037l-19.48-33.741c-6.728-11.653-21.72-15.499-33.227-8.523L296 186.718l3.475-162.204C299.763 11.061 288.937 0 275.48 0h-38.96c-13.456 0-24.283 11.061-23.994 24.514L216 186.718 77.265 102.607c-11.506-6.976-26.499-3.13-33.227 8.523l-19.48 33.741c-6.728 11.653-2.562 26.56 9.233 33.037L176 256 33.79 334.093c-11.795 6.477-15.961 21.384-9.232 33.037l19.48 33.741c6.728 11.653 21.721 15.499 33.227 8.523L216 325.282l-3.475 162.204C212.237 500.939 223.064 512 236.52 512h38.961c13.456 0 24.283-11.061 23.995-24.514L296 325.282l138.735 84.111c11.506 6.976 26.499 3.13 33.227-8.523l19.48-33.741c6.728-11.653 2.563-26.559-9.232-33.036z"
fill="currentColor"
/>
</svg>
</i>
</label>
</div>
<div
class="rbt"
style="outline: none; position: relative;"
tabindex="-1"
>
<div
style="display: flex; flex: 1; height: 100%; position: relative;"
>
<input
aria-autocomplete="both"
aria-expanded="false"
aria-haspopup="listbox"
autocomplete="off"
class="rbt-input-main form-control rbt-input"
placeholder="imagings.imaging.patient"
role="combobox"
type="text"
value=""
/>
<input
aria-hidden="true"
class="rbt-input-hint"
readonly=""
style="background-color: transparent; border-color: transparent; box-shadow: none; color: rgba(0, 0, 0, 0.35); left: 0px; pointer-events: none; position: absolute; top: 0px; width: 100%;"
tabindex="-1"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="col"
>
<div
class="visits"
>
<div
class="form-group"
>
<div>
<label
class="form-label"
for="visitSelect"
title="This is a required input"
>
patient.visits.label
<i
style="color: red;"
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-asterisk fa-w-16 "
data-icon="asterisk"
data-prefix="fas"
focusable="false"
role="img"
style="height: 7px; vertical-align: top; margin-left: 2px;"
viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M478.21 334.093L336 256l142.21-78.093c11.795-6.477 15.961-21.384 9.232-33.037l-19.48-33.741c-6.728-11.653-21.72-15.499-33.227-8.523L296 186.718l3.475-162.204C299.763 11.061 288.937 0 275.48 0h-38.96c-13.456 0-24.283 11.061-23.994 24.514L216 186.718 77.265 102.607c-11.506-6.976-26.499-3.13-33.227 8.523l-19.48 33.741c-6.728 11.653-2.562 26.56 9.233 33.037L176 256 33.79 334.093c-11.795 6.477-15.961 21.384-9.232 33.037l19.48 33.741c6.728 11.653 21.721 15.499 33.227 8.523L216 325.282l-3.475 162.204C212.237 500.939 223.064 512 236.52 512h38.961c13.456 0 24.283-11.061 23.995-24.514L296 325.282l138.735 84.111c11.506 6.976 26.499 3.13 33.227-8.523l19.48-33.741c6.728-11.653 2.563-26.559-9.232-33.036z"
fill="currentColor"
/>
</svg>
</i>
</label>
</div>
<div
class="rbt"
style="outline: none; position: relative;"
tabindex="-1"
>
<div
style="display: flex; flex: 1; height: 100%; position: relative;"
>
<input
aria-autocomplete="both"
aria-expanded="false"
aria-haspopup="listbox"
autocomplete="off"
class="rbt-input-main form-control rbt-input"
placeholder="-- Choose --"
role="combobox"
type="text"
value=""
/>
<input
aria-hidden="true"
class="rbt-input-hint"
readonly=""
style="background-color: transparent; border-color: transparent; box-shadow: none; color: rgba(0, 0, 0, 0.35); left: 0px; pointer-events: none; position: absolute; top: 0px; width: 100%;"
tabindex="-1"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="form-group"
>
<div>
<label
class="form-label"
for="imagingTypeTextInput"
title="This is a required input"
>
imagings.imaging.type
<i
style="color: red;"
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-asterisk fa-w-16 "
data-icon="asterisk"
data-prefix="fas"
focusable="false"
role="img"
style="height: 7px; vertical-align: top; margin-left: 2px;"
viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M478.21 334.093L336 256l142.21-78.093c11.795-6.477 15.961-21.384 9.232-33.037l-19.48-33.741c-6.728-11.653-21.72-15.499-33.227-8.523L296 186.718l3.475-162.204C299.763 11.061 288.937 0 275.48 0h-38.96c-13.456 0-24.283 11.061-23.994 24.514L216 186.718 77.265 102.607c-11.506-6.976-26.499-3.13-33.227 8.523l-19.48 33.741c-6.728 11.653-2.562 26.56 9.233 33.037L176 256 33.79 334.093c-11.795 6.477-15.961 21.384-9.232 33.037l19.48 33.741c6.728 11.653 21.721 15.499 33.227 8.523L216 325.282l-3.475 162.204C212.237 500.939 223.064 512 236.52 512h38.961c13.456 0 24.283-11.061 23.995-24.514L296 325.282l138.735 84.111c11.506 6.976 26.499 3.13 33.227-8.523l19.48-33.741c6.728-11.653 2.563-26.559-9.232-33.036z"
fill="currentColor"
/>
</svg>
</i>
</label>
</div>
<div
class="form-group"
>
<input
class="form-control"
id="imagingTypeTextInput"
placeholder="imagings.imaging.type"
type="text"
value=""
/>
<div
class="text-left ml-3 mt-1 text-small undefined invalid-feedback"
/>
</div>
</div>
<div
class="imaging-status"
>
<div
class="form-group"
>
<div>
<label
class="form-label"
for="statusSelect"
title="This is a required input"
>
imagings.imaging.status
<i
style="color: red;"
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-asterisk fa-w-16 "
data-icon="asterisk"
data-prefix="fas"
focusable="false"
role="img"
style="height: 7px; vertical-align: top; margin-left: 2px;"
viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M478.21 334.093L336 256l142.21-78.093c11.795-6.477 15.961-21.384 9.232-33.037l-19.48-33.741c-6.728-11.653-21.72-15.499-33.227-8.523L296 186.718l3.475-162.204C299.763 11.061 288.937 0 275.48 0h-38.96c-13.456 0-24.283 11.061-23.994 24.514L216 186.718 77.265 102.607c-11.506-6.976-26.499-3.13-33.227 8.523l-19.48 33.741c-6.728 11.653-2.562 26.56 9.233 33.037L176 256 33.79 334.093c-11.795 6.477-15.961 21.384-9.232 33.037l19.48 33.741c6.728 11.653 21.721 15.499 33.227 8.523L216 325.282l-3.475 162.204C212.237 500.939 223.064 512 236.52 512h38.961c13.456 0 24.283-11.061 23.995-24.514L296 325.282l138.735 84.111c11.506 6.976 26.499 3.13 33.227-8.523l19.48-33.741c6.728-11.653 2.563-26.559-9.232-33.036z"
fill="currentColor"
/>
</svg>
</i>
</label>
</div>
<div
class="rbt"
style="outline: none; position: relative;"
tabindex="-1"
>
<div
style="display: flex; flex: 1; height: 100%; position: relative;"
>
<input
aria-autocomplete="both"
aria-expanded="false"
aria-haspopup="listbox"
autocomplete="off"
class="rbt-input-main form-control rbt-input"
placeholder="-- Choose --"
role="combobox"
type="text"
value="imagings.status.requested"
/>
<input
aria-hidden="true"
class="rbt-input-hint"
readonly=""
style="background-color: transparent; border-color: transparent; box-shadow: none; color: rgba(0, 0, 0, 0.35); left: 0px; pointer-events: none; position: absolute; top: 0px; width: 100%;"
tabindex="-1"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="form-group"
>
<div
class="form-group"
>
<label
class="form-label"
for="ImagingNotesTextField"
>
imagings.imaging.notes
</label>
<div
class="form-group"
>
<textarea
class="form-control"
rows="4"
/>
<div
class="invalid-feedback"
/>
</div>
</div>
</div>
<div
class="row float-right"
>
<div
class="btn-group btn-group-lg mt-3"
>
<button
class="mr-2 btn btn-success"
type="button"
>
actions.save
</button>
<button
class="btn btn-danger"
type="button"
>
actions.cancel
</button>
</div>
</div>
</form>
</div>
`;

0 comments on commit 5228eab

Please sign in to comment.