From 86ca98344e51302618c6cbfeeb64bb78a9724364 Mon Sep 17 00:00:00 2001 From: Volodymyr Zakhovaiko Date: Fri, 10 Nov 2023 00:34:53 +0100 Subject: [PATCH] Moved SelectField tests to suites --- packages/uniforms-antd/__tests__/index.ts | 1 + .../uniforms-bootstrap3/__tests__/index.ts | 1 + .../uniforms-bootstrap4/__tests__/index.ts | 1 + .../uniforms-bootstrap5/__tests__/index.ts | 1 + packages/uniforms-material/__tests__/index.ts | 1 + packages/uniforms-mui/__tests__/index.ts | 1 + packages/uniforms-semantic/__tests__/index.ts | 1 + packages/uniforms-unstyled/__tests__/index.ts | 1 + packages/uniforms/__suites__/SelectField.tsx | 22 +++++++++++++++++++ packages/uniforms/__suites__/index.ts | 1 + 10 files changed, 31 insertions(+) create mode 100644 packages/uniforms/__suites__/SelectField.tsx diff --git a/packages/uniforms-antd/__tests__/index.ts b/packages/uniforms-antd/__tests__/index.ts index 8f0fbdb8b..f2f13980d 100644 --- a/packages/uniforms-antd/__tests__/index.ts +++ b/packages/uniforms-antd/__tests__/index.ts @@ -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); diff --git a/packages/uniforms-bootstrap3/__tests__/index.ts b/packages/uniforms-bootstrap3/__tests__/index.ts index 83ab14a6d..e888d6d58 100644 --- a/packages/uniforms-bootstrap3/__tests__/index.ts +++ b/packages/uniforms-bootstrap3/__tests__/index.ts @@ -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); diff --git a/packages/uniforms-bootstrap4/__tests__/index.ts b/packages/uniforms-bootstrap4/__tests__/index.ts index 0d7ded864..c02adb1e4 100644 --- a/packages/uniforms-bootstrap4/__tests__/index.ts +++ b/packages/uniforms-bootstrap4/__tests__/index.ts @@ -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); diff --git a/packages/uniforms-bootstrap5/__tests__/index.ts b/packages/uniforms-bootstrap5/__tests__/index.ts index bd1096e57..ff4ae6bc9 100644 --- a/packages/uniforms-bootstrap5/__tests__/index.ts +++ b/packages/uniforms-bootstrap5/__tests__/index.ts @@ -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); diff --git a/packages/uniforms-material/__tests__/index.ts b/packages/uniforms-material/__tests__/index.ts index 5d81b6d44..34a7a501a 100644 --- a/packages/uniforms-material/__tests__/index.ts +++ b/packages/uniforms-material/__tests__/index.ts @@ -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); diff --git a/packages/uniforms-mui/__tests__/index.ts b/packages/uniforms-mui/__tests__/index.ts index bb7fdb5b8..2bda7dbd1 100644 --- a/packages/uniforms-mui/__tests__/index.ts +++ b/packages/uniforms-mui/__tests__/index.ts @@ -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); diff --git a/packages/uniforms-semantic/__tests__/index.ts b/packages/uniforms-semantic/__tests__/index.ts index 1c5817f1a..5e300107c 100644 --- a/packages/uniforms-semantic/__tests__/index.ts +++ b/packages/uniforms-semantic/__tests__/index.ts @@ -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); diff --git a/packages/uniforms-unstyled/__tests__/index.ts b/packages/uniforms-unstyled/__tests__/index.ts index 98de11a8e..2abef5bdf 100644 --- a/packages/uniforms-unstyled/__tests__/index.ts +++ b/packages/uniforms-unstyled/__tests__/index.ts @@ -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); diff --git a/packages/uniforms/__suites__/SelectField.tsx b/packages/uniforms/__suites__/SelectField.tsx new file mode 100644 index 000000000..fd7f4056f --- /dev/null +++ b/packages/uniforms/__suites__/SelectField.tsx @@ -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, + options?: { + skipMuiTests?: boolean; + }, +) { + skipTestIf(options?.skipMuiTests)(' - renders a select', () => { + renderWithZod({ + element: , + schema: z.object({ x: z.enum(['a', 'b']) }), + }); + + expect(screen.getAllByRole('combobox')).toHaveLength(1); + }); +} diff --git a/packages/uniforms/__suites__/index.ts b/packages/uniforms/__suites__/index.ts index 20a088254..de6b16372 100644 --- a/packages/uniforms/__suites__/index.ts +++ b/packages/uniforms/__suites__/index.ts @@ -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';