-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
Migrated SelectField
tests to @testing-library/react
#1294
Conversation
SelectField
testsSelectField
tests to @testing-library/react
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1294 +/- ##
=======================================
Coverage 94.60% 94.61%
=======================================
Files 231 231
Lines 3821 3823 +2
Branches 1029 1030 +1
=======================================
+ Hits 3615 3617 +2
Misses 82 82
Partials 124 124 ☔ View full report in Codecov by Sentry. |
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.
Missing tests for
- AntD
- Material
- MUI
test('<SelectField> - renders a select which correctly reacts on change (uncheck) by value', () => { | ||
const onChange = jest.fn(); | ||
renderWithZod({ | ||
element: <SelectField fieldType={Array} name="x" onChange={onChange} />, | ||
schema: z.object({ x: z.enum(['a', 'b']) }), | ||
}); | ||
const select = screen.getByRole('listbox'); | ||
fireEvent.change(select, { target: { value: '' } }); | ||
expect(onChange).toHaveBeenCalledWith([]); | ||
}); | ||
|
||
test('<SelectField> - renders a select which correctly reacts on change (uncheck) by selectedIndex', () => { | ||
const onChange = jest.fn(); | ||
renderWithZod({ | ||
element: <SelectField fieldType={Array} name="x" onChange={onChange} />, | ||
schema: z.object({ x: z.enum(['a', 'b']) }), | ||
}); | ||
const select = screen.getByRole('listbox'); | ||
fireEvent.change(select, { target: { selectedIndex: -1 } }); | ||
expect(onChange).toHaveBeenCalledWith([]); | ||
}); | ||
|
||
test('<SelectField> - renders a select which correctly reacts on change (checked) by selectedIndex', () => { | ||
const onChange = jest.fn(); | ||
renderWithZod({ | ||
element: <SelectField fieldType={Array} name="x" onChange={onChange} />, | ||
schema: z.object({ x: z.enum(['a', 'b']) }), | ||
}); | ||
const select = screen.getByRole('listbox'); | ||
fireEvent.change(select, { target: { selectedIndex: 0 } }); | ||
expect(onChange).toHaveBeenCalledWith(['a']); | ||
}); |
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.
Can we add information to the test name that its type is fieldType={Array}
? We can name it multiple
.
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.
Sure.
Co-authored-by: Volodymyr Zakhovaiko <[email protected]>
Is part of #1130