From 7c46bb6d0f6719274b8ce4532769a9b1a4a2677c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Po=C5=9Bpiech?= Date: Fri, 16 Feb 2024 09:18:39 +0100 Subject: [PATCH] refactor --- packages/uniforms-antd/__tests__/index.ts | 1 + packages/uniforms/__suites__/ListItemField.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/uniforms-antd/__tests__/index.ts b/packages/uniforms-antd/__tests__/index.ts index 9ced608fa..348024350 100644 --- a/packages/uniforms-antd/__tests__/index.ts +++ b/packages/uniforms-antd/__tests__/index.ts @@ -49,6 +49,7 @@ describe('@RTL', () => { getListAddField: screen => screen.getByRole('img', { name: 'plus-square' }), }); suites.testListItemField(theme.ListItemField, { + isSelectCombobox: true, useInputAsSelectField: true, }); suites.testLongTextField(theme.LongTextField); diff --git a/packages/uniforms/__suites__/ListItemField.tsx b/packages/uniforms/__suites__/ListItemField.tsx index 0d0331744..8065f3798 100644 --- a/packages/uniforms/__suites__/ListItemField.tsx +++ b/packages/uniforms/__suites__/ListItemField.tsx @@ -7,6 +7,7 @@ import { renderWithZod } from './render-zod'; export function testListItemField( ListItemField: ComponentType, options?: { + isSelectCombobox?: boolean; useInputAsSelectField?: boolean; }, ) { @@ -46,6 +47,15 @@ export function testListItemField( if (options?.useInputAsSelectField) { expect(container.getElementsByTagName('input')).toHaveLength(3); + + if (options?.isSelectCombobox) { + expect(screen.getByRole('combobox')).toBeInTheDocument(); + } else { + expect(container.getElementsByTagName('input')?.[2]).toHaveAttribute( + 'name', + 'select', + ); + } } else { expect(container.getElementsByTagName('input')).toHaveLength(2); expect(container.getElementsByTagName('select')).toHaveLength(1);