diff --git a/packages/uniforms-bootstrap3/__tests__/index.ts b/packages/uniforms-bootstrap3/__tests__/index.ts index 83ab14a6d..f110a60b9 100644 --- a/packages/uniforms-bootstrap3/__tests__/index.ts +++ b/packages/uniforms-bootstrap3/__tests__/index.ts @@ -48,6 +48,7 @@ describe('@RTL', () => { suites.testListField(theme.ListField, { getListAddField: screen => screen.getByRole('button'), }); + suites.testListItemField(theme.ListItemField); suites.testLongTextField(theme.LongTextField); suites.testNestField(theme.NestField); suites.testNumField(theme.NumField); diff --git a/packages/uniforms-unstyled/__tests__/index.ts b/packages/uniforms-unstyled/__tests__/index.ts index 98de11a8e..892cbd0a2 100644 --- a/packages/uniforms-unstyled/__tests__/index.ts +++ b/packages/uniforms-unstyled/__tests__/index.ts @@ -46,6 +46,7 @@ describe('@RTL', () => { suites.testListField(theme.ListField, { getListAddField: screen => screen.getByRole('button'), }); + suites.testListItemField(theme.ListItemField); suites.testLongTextField(theme.LongTextField, { skipShowInlineErrorTests: true, }); diff --git a/packages/uniforms/__suites__/ListItemField.tsx b/packages/uniforms/__suites__/ListItemField.tsx new file mode 100644 index 000000000..edc27b57b --- /dev/null +++ b/packages/uniforms/__suites__/ListItemField.tsx @@ -0,0 +1,60 @@ +import { screen } from '@testing-library/react'; +// import userEvent from '@testing-library/user-event'; +import React, { ComponentType } from 'react'; +import z from 'zod'; + +import { renderWithZod } from './render-zod'; + +export function testListItemField(ListItemField: ComponentType) { + test(' - renders ListItemField', () => { + renderWithZod({ + element: , + schema: z.object({ x: z.number() }), + }); + + expect(screen.getByRole('button')).toBeInTheDocument(); + }); + + test(' - aaa', () => { + renderWithZod({ + element: , + schema: z.object({ x: z.string() }), + model: { x: 'Testttt' }, + }); + + expect(screen.getByRole('textbox')).toHaveAttribute('value', 'Testttt'); + }); + + // Bootstrap only + test(' - renders custom del field', () => { + renderWithZod({ + element: ( + Test} + /> + ), + schema: z.object({ x: z.string() }), + }); + + expect(screen.getByTestId('asdf')).toBeInTheDocument(); + }); + + test(' - renders ListDelField', () => { + renderWithZod({ + element: , + schema: z.object({ x: z.string() }), + }); + + expect(screen.getAllByRole('button')).toHaveLength(1); + }); + + test(' - renders AutoField', () => { + renderWithZod({ + element: , + schema: z.object({ x: z.number() }), + }); + + expect(screen.getAllByRole('spinbutton')).toHaveLength(1); + }); +} diff --git a/packages/uniforms/__suites__/index.ts b/packages/uniforms/__suites__/index.ts index 20a088254..04d72395f 100644 --- a/packages/uniforms/__suites__/index.ts +++ b/packages/uniforms/__suites__/index.ts @@ -10,6 +10,7 @@ export * from './HiddenField'; export * from './ListAddField'; export * from './ListDelField'; export * from './ListField'; +export * from './ListItemField'; export * from './LongTextField'; export * from './NestField'; export * from './NumField';