Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix createRenderInfo TypeError in default title case #2169

2 changes: 1 addition & 1 deletion packages/core/src/util/combinators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const createCombinatorRenderInfos = (
),
label:
subSchema.title ??
resolvedSubSchema.title ??
resolvedSubSchema?.title ??
`${keyword}-${subSchemaIndex}`,
};
});
31 changes: 31 additions & 0 deletions packages/core/test/util/combinators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,34 @@ test('createCombinatorRenderInfos - uses overrides for labels when subschemas ar
t.deepEqual(duaRenderInfo.label, 'DuaOverride');
t.deepEqual(lipaRenderInfo.label, 'LipaOverride');
});

const schemaWithoutRefs = {
type: 'object',
properties: {
widget: {
anyOf: [
{
type: 'object',
properties: { name: { type: 'string' } },
},
{
type: 'object',
properties: { name: { type: 'string' } },
},
],
},
},
};

test('createCombinatorRenderInfos - uses keyword + index when no labels provided', (t) => {
const [duaRenderInfo, lipaRenderInfo] = createCombinatorRenderInfos(
schemaWithoutRefs.properties.widget.anyOf,
schemaWithoutRefs,
'anyOf',
control,
'widget',
[]
);
t.deepEqual(duaRenderInfo.label, 'anyOf-0');
t.deepEqual(lipaRenderInfo.label, 'anyOf-1');
});
Loading