UNPKG

@tomino/dynamic-form-semantic-ui

Version:

Semantic UI form renderer based on dynamic form generation

62 lines 1.96 kB
import * as React from 'react'; import { prepareComponent } from '../../semantic/tests/common'; import { EditorState } from '../editor_state'; import { catalogue } from '../catalogue'; import { catalogueEditor } from '../../catalogue_editor'; import { EditorContext } from '../editor_context'; const formDefintion = { control: 'Stack', props: { gap: '12px' }, elements: [ { control: 'FormEditor', props: { formSource: { source: 'form' }, schemaSource: { source: 'schema' }, theme: 'light', editorHeight: '400px' } } ] }; describe('Form Editor', () => { const Component = prepareComponent(formDefintion, { type: 'object', properties: { schema: { type: 'string' }, form: { type: 'string' } } }, { form: JSON.stringify({ control: 'Form', elements: [{ props: { text: 'Yah!', control: 'Text' }, control: 'Text' }] }), schema: JSON.stringify({ type: 'object', properties: { name: { type: 'string', title: 'name' }, age: { type: 'number', title: 'age' }, car: { type: 'object', title: 'car', properties: { model: { type: 'string', title: 'model' }, year: { type: 'number', title: 'year' } } } } }) }, { addEditor: true, showReadOnly: false }); const editorContext = new EditorState(catalogue, catalogueEditor, {}); const Wrapper = () => (React.createElement(EditorContext.Provider, { value: editorContext }, React.createElement(Component, null))); return { component: Wrapper }; }); //# sourceMappingURL=form_editor.test.js.map