Skip to content

Commit 7d632d2

Browse files
committed
add Utils test
1 parent f368515 commit 7d632d2

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

packages/uswds/test/testUtils.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1-
import React from "react";
2-
import { render } from "@testing-library/react";
3-
import { FormProps } from "@rjsf/utils";
4-
import validator from "@rjsf/validator-ajv8";
1+
import { render } from '@testing-library/react';
2+
import { FormProps, RJSFSchema } from '@rjsf/utils';
3+
import validator from '@rjsf/validator-ajv8';
54

6-
import Theme from "../src/Theme"; // Import the USWDS theme
7-
import Form from "../src/Form"; // Import the USWDS Form
5+
import Theme from '../src/Theme';
6+
import Form from '../src/Form';
87

98
export function createFormComponent<T = any>(props: FormProps<T>) {
10-
return render(<Form validator={validator} {...props} theme={Theme} />);
9+
const { schema, uiSchema, formData, ...rest } = props;
10+
return render(
11+
<Form
12+
schema={schema}
13+
uiSchema={uiSchema}
14+
formData={formData}
15+
validator={validator}
16+
theme={Theme} // Pass the theme explicitly if needed
17+
{...rest}
18+
/>,
19+
);
1120
}
1221

13-
// You can add other common test utilities here if needed
22+
export function createSandbox() {
23+
const schema: RJSFSchema = {
24+
type: 'string',
25+
};
26+
return createFormComponent({ schema });
27+
}

0 commit comments

Comments
 (0)