diff --git a/packages/bootstrap-4/test/Array.test.tsx b/packages/bootstrap-4/test/Array.test.tsx index c21977bdba..130906967a 100644 --- a/packages/bootstrap-4/test/Array.test.tsx +++ b/packages/bootstrap-4/test/Array.test.tsx @@ -2,6 +2,27 @@ import React from 'react'; import Form from "../src/index"; import { JSONSchema7 } from "json-schema"; import renderer from "react-test-renderer"; +import { ArrayFieldTemplateProps, UiSchema } from '@rjsf/core'; + +const ArrayFieldTemplate = (props: ArrayFieldTemplateProps) => { + const title: string = props.uiSchema['ui:title'] || props.title || ''; + const description: string = props.uiSchema['ui:description'] || props.schema.description || ''; + const { TitleField, DescriptionField } = props; + return ( +
+ {title && } + {description && } + {props.items.map(item =>
{item.children}
)} +
+ ); +} describe("array fields", () => { test("array", () => { @@ -47,4 +68,32 @@ describe("array fields", () => { .toJSON(); expect(tree).toMatchSnapshot(); }); + test("customization", () => { + const schema: JSONSchema7 = { + type: "array", + title: "my-title", + description: "my-description", + items: [ + { + type: "boolean", + default: true + } + ] + }; + const uiSchema: UiSchema = { + "ui:ArrayFieldTemplate": ArrayFieldTemplate + } + const fields = { + TitleField: ({ title }: any) => ( +
{title}
+ ), + DescriptionField: ({ description }: any) => ( +
{description}
+ ), + } + const tree = renderer + .create(
) + .toJSON(); + expect(tree).toMatchSnapshot(); + }); }); \ No newline at end of file diff --git a/packages/bootstrap-4/test/__snapshots__/Array.test.tsx.snap b/packages/bootstrap-4/test/__snapshots__/Array.test.tsx.snap index 426bf6e496..1173174d80 100644 --- a/packages/bootstrap-4/test/__snapshots__/Array.test.tsx.snap +++ b/packages/bootstrap-4/test/__snapshots__/Array.test.tsx.snap @@ -153,6 +153,69 @@ exports[`array fields checkboxes 1`] = `
`; +exports[`array fields customization 1`] = ` +
+
+
+
+ my-title +
+
+ my-description +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+`; + exports[`array fields fixed array 1`] = `