From 15e86e2e7ac1a6dfd78118f073097d0d24ac258c Mon Sep 17 00:00:00 2001 From: Nice <95516163+nicetooo@users.noreply.github.com> Date: Mon, 23 Oct 2023 05:56:42 +0000 Subject: [PATCH 1/2] feat: test added --- .../src/__tests__/schema.markup.spec.tsx | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/packages/react/src/__tests__/schema.markup.spec.tsx b/packages/react/src/__tests__/schema.markup.spec.tsx index ad042ead1e1..93fcd2c92ad 100644 --- a/packages/react/src/__tests__/schema.markup.spec.tsx +++ b/packages/react/src/__tests__/schema.markup.spec.tsx @@ -1054,3 +1054,86 @@ test('records scope', async () => { expect(queryByTestId('text')?.textContent).toBe('3') }) }) + +test('propsRecursion as true', () => { + const form = createForm() + const CustomObject: React.FC = () => { + const schema = useFieldSchema() + return ( +
+ { + if (schema['x-component'] === 'Input') { + return false + } + return true + }} + /> +
+ ) + } + + const SchemaField = createSchemaField({ + components: { + Input, + CustomObject, + }, + }) + const { queryAllByTestId } = render( + + + + + + + + + + + ) + expect(queryAllByTestId('input').length).toEqual(0) + expect(queryAllByTestId('object').length).toEqual(1) +}) + +test('propsRecursion as empty', () => { + const form = createForm() + const CustomObject: React.FC = () => { + const schema = useFieldSchema() + return ( +
+ { + if (schema['x-component'] === 'Input') { + return false + } + return true + }} + /> +
+ ) + } + + const SchemaField = createSchemaField({ + components: { + Input, + CustomObject, + }, + }) + const { queryAllByTestId } = render( + + + + + + + + + + + ) + expect(queryAllByTestId('input').length).toEqual(1) + expect(queryAllByTestId('object').length).toEqual(1) +}) From 7373754adc678f5a35364c4209e51af3beab1021 Mon Sep 17 00:00:00 2001 From: Nice <95516163+nicetooo@users.noreply.github.com> Date: Mon, 23 Oct 2023 06:01:54 +0000 Subject: [PATCH 2/2] fix: filterProperties test case --- packages/react/src/__tests__/schema.markup.spec.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react/src/__tests__/schema.markup.spec.tsx b/packages/react/src/__tests__/schema.markup.spec.tsx index 93fcd2c92ad..821a3074940 100644 --- a/packages/react/src/__tests__/schema.markup.spec.tsx +++ b/packages/react/src/__tests__/schema.markup.spec.tsx @@ -351,8 +351,8 @@ describe('recursion field', () => { { - if (schema['x-component'] === 'Input') return - return true + if (schema['x-component'] === 'Input') return true + return false }} />