Skip to content

Commit

Permalink
Adds support for additional properties (rjsf-team#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
monwabisi-gaga authored Jul 8, 2021
1 parent a56d4bc commit 404f6d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/formBuilder/FormBuilder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,31 @@ describe('FormBuilder', () => {
.map((error) => error.text());
expect(errors).toEqual([]);
});

it('validates additionalProperties as a valid property', () => {
const jsonSchema = {
$schema: `http://json-schema.org/draft-07/schema#`,
properties: {},
required: [],
additionalProperties: false,
};

const props = {
schema: JSON.stringify(jsonSchema),
uiSchema: '{}',
onChange: jest.fn(() => {}),
mods: {},
className: 'my-form-builder',
};

const div = document.createElement('div');
document.body.appendChild(div);
const wrapper = mount(<FormBuilder {...props} />, { attachTo: div });
const errors = wrapper
.find('.alert-warning')
.first()
.find('li')
.map((error) => error.text());
expect(errors).toEqual([]);
});
});
1 change: 1 addition & 0 deletions src/formBuilder/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const supportedPropertyParameters = new Set([
'$id',
'$schema',
'meta',
'additionalProperties',
]);

const supportedUiParameters = new Set([
Expand Down

0 comments on commit 404f6d1

Please sign in to comment.