Skip to content

Commit

Permalink
chore: update formTests
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMario committed Jun 25, 2024
1 parent 51a8945 commit 5a4d919
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 0 deletions.
198 changes: 198 additions & 0 deletions packages/antd/test/__snapshots__/Form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2674,6 +2674,129 @@ exports[`single fields select field multiple choice enumDisabled 1`] = `
</form>
`;

exports[`single fields select field multiple choice enumDisabled using checkboxes 1`]=`
<form
className="rjsf"
noValidate={false}
onSubmit={[Function]}
>
<div
className="form-group field field-array"
>
<div
className="checkboxes"
id="root"
>
<div
className="checkbox "
>
<label>
<span>
<input
aria-describedby="root__error root__description root__help"
autoFocus={false}
checked={false}
disabled={false}
id="root-0"
name="root"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
type="checkbox"
value="0"
/>
<span>
foo
</span>
</span>
</label>
</div>
<div
className="checkbox disabled"
>
<label>
<span>
<input
aria-describedby="root__error root__description root__help"
autoFocus={false}
checked={false}
disabled={true}
id="root-1"
name="root"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
type="checkbox"
value="1"
/>
<span>
bar
</span>
</span>
</label>
</div>
<div
className="checkbox "
>
<label>
<span>
<input
aria-describedby="root__error root__description root__help"
autoFocus={false}
checked={false}
disabled={false}
id="root-2"
name="root"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
type="checkbox"
value="2"
/>
<span>
fuzz
</span>
</span>
</label>
</div>
<div
className="checkbox "
>
<label>
<span>
<input
aria-describedby="root__error root__description root__help"
autoFocus={false}
checked={false}
disabled={false}
id="root-3"
name="root"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
type="checkbox"
value="3"
/>
<span>
qux
</span>
</span>
</label>
</div>
</div>
</div>
<div>
<button
className="btn btn-info "
disabled={false}
type="submit"
>
Submit
</button>
</div>
</form>
`;

exports[`single fields select field multiple choice formData 1`] = `
<form
className="rjsf"
Expand Down Expand Up @@ -3269,6 +3392,81 @@ exports[`single fields select field single choice enumDisabled 1`] = `
</form>
`;

export[`single fields select field single choice enumDisabled using radio widget 1`] = `
<form
className="rjsf"
noValidate={false}
onSubmit={[Function]}
>
<div
className="form-group field field-string"
>
<div
className="field-radio-group"
id="root"
>
<div
className="radio "
>
<label>
<span>
<input
aria-describedby="root__error root__description root__help"
autoFocus={false}
checked={false}
disabled={false}
id="root-0"
name="root"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
type="radio"
value="0"
/>
<span>
foo
</span>
</span>
</label>
</div>
<div
className="radio disabled"
>
<label>
<span>
<input
aria-describedby="root__error root__description root__help"
autoFocus={false}
checked={false}
disabled={true}
id="root-1"
name="root"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
type="radio"
value="1"
/>
<span>
bar
</span>
</span>
</label>
</div>
</div>
</div>
<div>
<button
className="btn btn-info "
disabled={false}
type="submit"
>
Submit
</button>
</div>
</form>
`;
exports[`single fields select field single choice formData 1`] = `
<form
className="rjsf"
Expand Down
30 changes: 30 additions & 0 deletions packages/snapshot-tests/src/formTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ export function formTests(Form: ComponentType<FormProps>, customOptions: FormRen
const tree = renderer.create(<Form schema={schema} uiSchema={uiSchema} validator={validator} />).toJSON();
expect(tree).toMatchSnapshot();
});
test('select field single choice enumDisabled using radio widget', () => {
const schema: RJSFSchema = {
type: 'string',
enum: ['foo', 'bar'],
};
const uiSchema = {
'ui:widget': 'radio',
'ui:enumDisabled': ['bar'],
};
const tree = renderer.create(<Form schema={schema} uiSchema={uiSchema} validator={validator} />).toJSON();
expect(tree).toMatchSnapshot();
});
test('select field multiple choice enumDisabled', () => {
const schema: RJSFSchema = {
type: 'array',
Expand All @@ -226,6 +238,24 @@ export function formTests(Form: ComponentType<FormProps>, customOptions: FormRen
.toJSON();
expect(tree).toMatchSnapshot();
});
test('select field multiple choice enumDisabled using checkboxes', () => {
const schema: RJSFSchema = {
type: 'array',
items: {
type: 'string',
enum: ['foo', 'bar', 'fuzz', 'qux'],
},
uniqueItems: true,
};
const uiSchema = {
'ui:widget': 'checkboxes',
'ui:enumDisabled': ['bar'],
};
const tree = renderer
.create(<Form schema={schema} uiSchema={uiSchema} validator={validator} />, customOptions.selectMulti)
.toJSON();
expect(tree).toMatchSnapshot();
});
test('select field single choice formData', () => {
const schema: RJSFSchema = {
type: 'string',
Expand Down

0 comments on commit 5a4d919

Please sign in to comment.