Skip to content

Commit 00dd86e

Browse files
committed
Add test for experimental_customMergeAllOf
1 parent 5ac606b commit 00dd86e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

packages/utils/test/schema/retrieveSchemaTest.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,37 @@ export default function retrieveSchemaTest(testValidator: TestValidatorType) {
822822
default: 'hi',
823823
});
824824
});
825+
826+
it('should use experimental_customMergeAllOf when provided', () => {
827+
const schema: RJSFSchema = {
828+
allOf: [
829+
{
830+
type: 'object',
831+
properties: {
832+
string: { type: 'string' },
833+
},
834+
},
835+
{
836+
type: 'object',
837+
properties: {
838+
number: { type: 'number' },
839+
},
840+
},
841+
],
842+
};
843+
const rootSchema: RJSFSchema = { definitions: {} };
844+
const formData = {};
845+
const customMergeAllOf = jest.fn().mockReturnValue({
846+
type: 'object',
847+
properties: { string: { type: 'string' }, number: { type: 'number' } },
848+
});
849+
850+
expect(retrieveSchema(testValidator, schema, rootSchema, formData, customMergeAllOf)).toEqual({
851+
type: 'object',
852+
properties: { string: { type: 'string' }, number: { type: 'number' } },
853+
});
854+
expect(customMergeAllOf).toHaveBeenCalledWith(schema);
855+
});
825856
});
826857
describe('Conditional schemas (If, Then, Else)', () => {
827858
it('should resolve if, then', () => {

0 commit comments

Comments
 (0)