Skip to content
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

Merged
merged 15 commits into from
Apr 5, 2024

Conversation

zaxovaiko
Copy link
Member

@zaxovaiko zaxovaiko commented Nov 9, 2023

Is part of #1130

@zaxovaiko zaxovaiko self-assigned this Nov 9, 2023
@github-actions github-actions bot added Area: Core Affects the uniforms package Area: Theme Affects some of the theme packages Theme: AntD Affects the uniforms-antd package Theme: Bootstrap 3 Affects the uniforms-bootstrap3 package Theme: Bootstrap 4 Affects the uniforms-bootstrap4 package Theme: Bootstrap 5 Affects the uniforms-bootstrap5 package Theme: Material-UI Affects the uniforms-material package Theme: MUI Affects the uniforms-mui package Theme: Semantic UI Affects the uniforms-semantic package Theme: Unstyled Affects the uniforms-unstyled package labels Nov 9, 2023
@kestarumper kestarumper changed the title Rewrite SelectField tests Migrated SelectField tests to @testing-library/react Dec 1, 2023
@github-actions github-actions bot added the Area: Infra Affects the repository itself (e.g., CI, dependencies) label Feb 9, 2024
Copy link

codecov bot commented Feb 9, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 94.61%. Comparing base (8b3f6f5) to head (b90343c).

Files Patch % Lines
packages/uniforms-antd/src/SelectField.tsx 87.50% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@zaxovaiko zaxovaiko marked this pull request as ready for review March 1, 2024 00:41
Copy link
Member

@kestarumper kestarumper left a 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

packages/uniforms/__suites__/render-zod.tsx Show resolved Hide resolved
Comment on lines 67 to 98
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']);
});
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Monteth
Monteth previously approved these changes Mar 8, 2024
@kestarumper kestarumper merged commit 49715f4 into master Apr 5, 2024
6 of 7 checks passed
@kestarumper kestarumper deleted the select-field-tests branch April 5, 2024 11:03
@kestarumper kestarumper linked an issue Apr 7, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Core Affects the uniforms package Area: Infra Affects the repository itself (e.g., CI, dependencies) Area: Theme Affects some of the theme packages Theme: AntD Affects the uniforms-antd package Theme: Bootstrap 3 Affects the uniforms-bootstrap3 package Theme: Bootstrap 4 Affects the uniforms-bootstrap4 package Theme: Bootstrap 5 Affects the uniforms-bootstrap5 package Theme: Material-UI Affects the uniforms-material package Theme: MUI Affects the uniforms-mui package Theme: Semantic UI Affects the uniforms-semantic package Theme: Unstyled Affects the uniforms-unstyled package
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants