Closed
Description
Hi 👋 Thanks for the great library! Think I may have found a bug but if not I would love to know what I'm doing wrong here.
react-testing-library
version: 5.4.4react
version: 16.7.0node
version: 10.15.0npm
(oryarn
) version: yarn 1.10.1
Relevant code or config:
test('disabled checkbox cannot be selected', () => {
const onChange = jest.fn()
const {getByTestId} = render(
<input
type="checkbox"
onChange={onChange}
data-testid="checkbox"
disabled
/>,
)
const checkbox = getByTestId('checkbox')
fireEvent.click(checkbox)
expect(onChange).not.toHaveBeenCalled() // this fails
})
What you did:
I wrote a test to check that a checkbox onChange
function would not be called if the checkbox is disabled.
What happened:
The test failed saying that the onChange
function had been called.
Reproduction:
https://codesandbox.io/s/91684p354
Problem description:
The test should pass. onChange
functions should not be called in the test if the checkbox is disabled.
Suggested solution:
Not sure, haven't looked into the code yet.