-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add tests for checkbox #121
Conversation
<Checkbox name="test-checkbox" label="Test Checkbox" labelClassName="custom-label-class" readOnly /> | ||
); | ||
|
||
const checkboxWrapper = screen.getByLabelText('Test Checkbox')?.parentElement?.parentElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was quite hard to test, which hints that the implementation might not be great.
Deploying with
|
Latest commit: |
3b14bd2
|
Status: | ✅ Deploy successful! |
Preview URL: | https://c44240bd.deriv-ui.pages.dev |
Branch Preview URL: | https://add-tests-for-checkbox.deriv-ui.pages.dev |
test('triggers onChange event when clicked', () => { | ||
const handleChange = jest.fn(); | ||
render(<Checkbox name="test-checkbox" onChange={handleChange} />); | ||
fireEvent.click(screen.getByRole('checkbox')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just out of curiosity 🤔
would it be better to use userEvent
? or in this case it doesn't make any difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah absolutely. Thanks Shayan. Also switched that screen.
to using the result from the render, which I find more pure.
1836373
to
3b14bd2
Compare
🎉 This PR is included in version 1.10.11 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Add some unit tests for the Checkbox component.