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 #211 from codyarose/codyarose
Browse files Browse the repository at this point in the history
Incidents.test.tsx - refactored improvements and setup function
  • Loading branch information
JacobMGEvans authored Jan 3, 2021
2 parents b055637 + afee1a2 commit 12d80ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/__tests__/incidents/Incidents.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,27 @@ describe('Incidents', () => {
components: { sidebarCollapsed: false },
} as any)

// eslint-disable-next-line react/prop-types
const Wrapper: React.FC = ({ children }) => (
return render(
<Provider store={store}>
<MemoryRouter initialEntries={[path]}>
<titleUtil.TitleProvider>{children}</titleUtil.TitleProvider>
<titleUtil.TitleProvider>
<Incidents />
</titleUtil.TitleProvider>
</MemoryRouter>
</Provider>
</Provider>,
)

return render(<Incidents />, { wrapper: Wrapper })
}

describe('routing', () => {
describe('/incidents/new', () => {
it('The new incident screen when /incidents/new is accessed', () => {
setup([Permissions.ReportIncident], '/incidents/new')
expect(screen.getAllByText(/incidents.reports/i)[0]).toBeInTheDocument()
expect(screen.getByRole('form', { name: /report incident form/i })).toBeInTheDocument()
})

it('should not navigate to /incidents/new if the user does not have ReportIncident permissions', () => {
setup([], '/incidents/new')
expect(screen.queryByText(/incidents.reports/i)).not.toBeInTheDocument()
const { container } = setup([], '/incidents/new')
expect(container).toMatchInlineSnapshot(`<div />`)
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/incidents/report/ReportIncident.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const ReportIncident = () => {
}

return (
<form>
<form aria-label="Report Incident form">
<Row>
<Column md={6}>
<DateTimePickerWithLabelFormGroup
Expand Down

0 comments on commit 12d80ce

Please sign in to comment.