Skip to content

Commit

Permalink
rjsf-team#4079 improved test
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdallah Al-Soqatri committed Feb 27, 2024
1 parent 8801ec3 commit f59e2fb
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/core/test/Form.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4020,31 +4020,37 @@ describe('Form omitExtraData and liveOmit', () => {
properties: {
foo: { type: 'string' },
},
required: ['foo'],
};

const extraErrors = {
foo: {
__errors: ['foo'],
},
};

const { comp } = createFormComponent({
const { comp, node } = createFormComponent({
schema,
extraErrors,
liveValidate: true,
formData: { foo: 1 },
});

Simulate.submit(node);
expect(comp.state.errorSchema).eql({ foo: { __errors: ["must have required property 'foo'"] } });
expect(comp.state.errors).eql([
{
message: "must have required property 'foo'",
property: 'foo',
name: 'required',
params: {
missingProperty: 'foo',
},
schemaPath: '#/required',
stack: "must have required property 'foo'",
},
]);

// Changing schema to reset errors state.
setProps(comp, {
schema: {
type: 'object',
properties: {
foo: { type: 'string' },
},
required: ['foo'],
},
});

expect(comp.state.errorSchema).eql({});
expect(comp.state.errors).eql([]);
});
Expand Down

0 comments on commit f59e2fb

Please sign in to comment.