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

Commit

Permalink
test: implemented unit tests for visualize tab
Browse files Browse the repository at this point in the history
  • Loading branch information
yosephAHMED committed Aug 12, 2020
1 parent d73a3e7 commit a105748
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/__tests__/shared/components/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Sidebar', () => {
Permissions.ViewLabs,
Permissions.ViewIncidents,
Permissions.ViewIncident,
Permissions.ViewIncidentWidgets,
Permissions.ReportIncident,
Permissions.ReadVisits,
Permissions.AddVisit,
Expand Down Expand Up @@ -473,6 +474,24 @@ describe('Sidebar', () => {
})
})

it('should render the incidents visualize link', () => {
const wrapper = setup('/incidents')

const listItems = wrapper.find(ListItem)

expect(listItems.at(8).text().trim()).toEqual('incidents.visualize.label')
})

it('should not render the incidents visualize link when user does not have the view incident widgets privileges', () => {
const wrapper = setupNoPermissions('/incidents')

const listItems = wrapper.find(ListItem)

listItems.forEach((_, i) => {
expect(listItems.at(i).text().trim()).not.toEqual('incidents.visualize.label')
})
})

it('main incidents link should be active when the current path is /incidents', () => {
const wrapper = setup('/incidents')

Expand Down Expand Up @@ -515,6 +534,19 @@ describe('Sidebar', () => {
expect(history.location.pathname).toEqual('/incidents/new')
})

it('should navigate to /incidents/visualize when the incidents visualize link is clicked', () => {
const wrapper = setup('/incidents')

const listItems = wrapper.find(ListItem)

act(() => {
const onClick = listItems.at(8).prop('onClick') as any
onClick()
})

expect(history.location.pathname).toEqual('/incidents/visualize')
})

it('incidents list link should be active when the current path is /incidents', () => {
const wrapper = setup('/incidents')

Expand Down

0 comments on commit a105748

Please sign in to comment.