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 #19 from proful/master
Browse files Browse the repository at this point in the history
Convert ButtonToolBar to RTL
  • Loading branch information
JacobMGEvans authored Dec 17, 2020
2 parents 5228eab + 07817e8 commit 1c77c4b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/__tests__/page-header/button-toolbar/ButtonToolBar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from '@hospitalrun/components'
import { mount } from 'enzyme'
import { render, screen } from '@testing-library/react'
import React from 'react'

import * as ButtonBarProvider from '../../../page-header/button-toolbar/ButtonBarProvider'
Expand All @@ -17,17 +17,17 @@ describe('Button Tool Bar', () => {
]
jest.spyOn(ButtonBarProvider, 'useButtons').mockReturnValue(buttons)

const wrapper = mount(<ButtonToolBar />).find('.button-toolbar')
render(<ButtonToolBar />)
const renderedButtons = screen.getAllByRole('button')

expect(wrapper.childAt(0).getElement()).toEqual(buttons[0])
expect(wrapper.childAt(1).getElement()).toEqual(buttons[1])
expect(renderedButtons[0]).toHaveTextContent(/test 1/i)
expect(renderedButtons[1]).toHaveTextContent(/test 2/i)
})

it('should return null when there is no button in the provider', () => {
jest.spyOn(ButtonBarProvider, 'useButtons').mockReturnValue([])

const wrapper = mount(<ButtonToolBar />)

expect(wrapper.html()).toBeNull()
render(<ButtonToolBar />)
expect(screen.queryByRole('button')).not.toBeInTheDocument()
})
})

0 comments on commit 1c77c4b

Please sign in to comment.