Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('FormState change', ()=>{
const broadCastWrapper = ({ children }) => {
return {children}
}
const form = createForm({})
expect(form.getFormState(state => state.mounted)).toEqual(false)
expect(form.getFormState(state => state.initialized)).toEqual(true)
expect(form.getFormState(state => state.editable)).toEqual(undefined)
const { result } = renderHook(() => useForm({ form }), { wrapper: broadCastWrapper })
expect(result.current.getFormState(state => state.mounted)).toEqual(true)
expect(result.current.getFormState(state => state.initialized)).toEqual(true)
expect(result.current.getFormState(state => state.editable)).toEqual(undefined)
})
test('return createForm instance', ()=>{
const broadCastWrapper = ({ children }) => {
return {children}
}
const opts = {}
const form = createForm(opts)
const { result } = renderHook(() => useForm({ form }), { wrapper: broadCastWrapper })
expect(result.current).toEqual(form)
})
const form = useMemo(() => {
return alreadyHaveForm ? options.form : createForm(options)
}, [])
constructor(props) {
super(props)
this.initialized = false
this.form = createForm({
initialValues: props.defaultValue || props.initialValues,
values: props.value,
effects: props.effects,
subscribes: props.subscribes,
schema: props.schema,
editable: props.editable,
traverse: schema => {
const traverse =
schema &&
getFormFieldPropsTransformer(schema['x-component'] || schema.type)
return traverse ? traverse(schema) : schema
},
onSubmit: this.onSubmitHandler(props),
onFormChange: this.onFormChangeHandler(props),
onFieldChange: this.onFieldChangeHandler(props),
onValidateFailed: this.onValidateFailed(props),