UNPKG

@rjsf/core

Version:

A simple React component capable of building HTML forms out of a JSON schema.

24 lines (23 loc) 1.03 kB
import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, createSchemaUtils, englishStringTranslator, } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; import getDefaultRegistry from './getDefaultRegistry.js'; /** Use for react testing library tests where we directly test the component rather than testing inside a Form */ export default function getTestRegistry(rootSchema, fields = {}, templates = {}, widgets = {}, formContext = {}, globalFormOptions = { idPrefix: DEFAULT_ID_PREFIX, idSeparator: DEFAULT_ID_SEPARATOR, useFallbackUiForUnsupportedType: false, }) { const defaults = getDefaultRegistry(); const schemaUtils = createSchemaUtils(validator, rootSchema); return { fields: { ...defaults.fields, ...fields }, templates: { ...defaults.templates, ...templates }, widgets: { ...defaults.widgets, ...widgets }, formContext, rootSchema, schemaUtils, translateString: englishStringTranslator, globalFormOptions, }; }