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

Commit

Permalink
test(sidebar.test.tsx): update imaging tests to now use RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-r-slight committed Dec 19, 2020
1 parent 48c69e1 commit 3fba22b
Showing 1 changed file with 27 additions and 67 deletions.
94 changes: 27 additions & 67 deletions src/__tests__/shared/components/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -512,120 +512,80 @@ describe('Sidebar', () => {
})
})

/*
describe('medications links', () => {
it('should render the main medications link', () => {
const wrapper = setup('/medications')
render('/medications')

const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.label')
expect(medicationsIndex).not.toBe(-1)
expect(screen.getByText(/medications.label/i)).toBeInTheDocument()
})

it('should render the new medications request link', () => {
const wrapper = setup('/medications')
const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.new')
render('/medications')

expect(medicationsIndex).not.toBe(-1)
expect(screen.getByText(/medications.requests.new/i)).toBeInTheDocument()
})

it('should not render the new medications request link when user does not have request medications privileges', () => {
const wrapper = setupNoPermissions('/medications')
renderNoPermissions('/medications')

const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.new')
expect(medicationsIndex).toBe(-1)
expect(screen.queryByText(/medications.requests.new/i)).not.toBeInTheDocument()
})

it('should render the medications list link', () => {
const wrapper = setup('/medications')
const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.label')
render('/medications')

expect(medicationsIndex).not.toBe(-1)
expect(screen.getByText(/medications.requests.label/i)).toBeInTheDocument()
})

it('should not render the medications list link when user does not have view medications privileges', () => {
const wrapper = setupNoPermissions('/medications')
renderNoPermissions('/medications')

const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.label')
expect(medicationsIndex).toBe(-1)
expect(screen.queryByText(/medications.requests.label/i)).not.toBeInTheDocument()
})

it('main medications link should be active when the current path is /medications', () => {
const wrapper = setup('/medications')
const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.label')
const { container } = render('/medications')

expect(listItems.at(medicationsIndex).prop('active')).toBeTruthy()
expect(container.querySelector('.active')).toHaveTextContent(/medications.label/i)
})

it('should navigate to /medications when the main lab link is clicked', () => {
const wrapper = setup('/')
const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.label')
render('/')

act(() => {
const onClick = listItems.at(medicationsIndex).prop('onClick') as any
onClick()
})
userEvent.click(screen.getByText(/medications.label/i))

expect(history.location.pathname).toEqual('/medications')
})

it('new lab request link should be active when the current path is /medications/new', () => {
const wrapper = setup('/medications/new')
const { container } = render('/medications/new')

const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.new')
expect(listItems.at(medicationsIndex).prop('active')).toBeTruthy()
expect(container.querySelectorAll('.active')[1]).toHaveTextContent(
/medications.requests.new/i,
)
})

it('should navigate to /medications/new when the new medications link is clicked', () => {
const wrapper = setup('/medications')
const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.new')
act(() => {
const onClick = listItems.at(medicationsIndex).prop('onClick') as any
onClick()
})
render('/medications')

userEvent.click(screen.getByText(/medications.requests.new/i))
expect(history.location.pathname).toEqual('/medications/new')
})

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

const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.label')
expect(listItems.at(medicationsIndex).prop('active')).toBeTruthy()
expect(container.querySelectorAll('.active')[1]).toHaveTextContent(
/medications.requests.label/i,
)
})

it('should navigate to /medications when the medications list link is clicked', () => {
const wrapper = setup('/medications/new')
render('/medications/new')

const listItems = wrapper.find(ListItem)
const medicationsIndex = getIndex(listItems, 'medications.requests.label')
act(() => {
const onClick = listItems.at(medicationsIndex).prop('onClick') as any
onClick()
})
userEvent.click(screen.getByText(/medications.requests.label/i))

expect(history.location.pathname).toEqual('/medications')
})
}) */
})
})

0 comments on commit 3fba22b

Please sign in to comment.