Skip to content

Commit

Permalink
Moved SelectField tests to suites
Browse files Browse the repository at this point in the history
  • Loading branch information
zaxovaiko committed Nov 9, 2023
1 parent 1fff338 commit 86ca983
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/uniforms-antd/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('@RTL', () => {
suites.testRadioField(theme.RadioField, { skipHtmlAttributesTest: true });
// FIXME: AntD has problem with toHaveValue check
suites.testSubmitField(theme.SubmitField, { skipValueTest: true });
suites.testSelectField(theme.SelectField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
Expand Down
1 change: 1 addition & 0 deletions packages/uniforms-bootstrap3/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('@RTL', () => {
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
Expand Down
1 change: 1 addition & 0 deletions packages/uniforms-bootstrap4/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('@RTL', () => {
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
Expand Down
1 change: 1 addition & 0 deletions packages/uniforms-bootstrap5/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('@RTL', () => {
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
Expand Down
1 change: 1 addition & 0 deletions packages/uniforms-material/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('@RTL', () => {
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
Expand Down
1 change: 1 addition & 0 deletions packages/uniforms-mui/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('@RTL', () => {
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
Expand Down
1 change: 1 addition & 0 deletions packages/uniforms-semantic/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('@RTL', () => {
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
Expand Down
1 change: 1 addition & 0 deletions packages/uniforms-unstyled/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('@RTL', () => {
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
suites.testRadioField(theme.RadioField);
suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
suites.testTextField(theme.TextField);
suites.testValidatedForm(theme.ValidatedForm);
Expand Down
22 changes: 22 additions & 0 deletions packages/uniforms/__suites__/SelectField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { screen } from '@testing-library/react';
import React, { ComponentType } from 'react';
import z from 'zod';

import { renderWithZod } from './render-zod';
import { skipTestIf } from './skipTestIf';

export function testSelectField(
SelectField: ComponentType<any>,
options?: {
skipMuiTests?: boolean;
},
) {
skipTestIf(options?.skipMuiTests)('<SelectField> - renders a select', () => {
renderWithZod({
element: <SelectField name="x" />,
schema: z.object({ x: z.enum(['a', 'b']) }),
});

expect(screen.getAllByRole('combobox')).toHaveLength(1);
});
}
1 change: 1 addition & 0 deletions packages/uniforms/__suites__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './NestField';
export * from './NumField';
export * from './QuickForm';
export * from './RadioField';
export * from './SelectField';
export * from './SubmitField';
export * from './TextField';
export * from './ValidatedForm';
Expand Down

0 comments on commit 86ca983

Please sign in to comment.