import React from 'react'; import { renderToString } from 'react-dom/server'; import { useController } from '../useController'; import { useForm } from '../useForm'; import { FormProvider, useFormContext } from '../useFormContext'; import { useFormState } from '../useFormState'; import { useWatch } from '../useWatch'; describe('FormProvider', () => { it('should work correctly with Controller, useWatch, useFormState.', () => { const App = () => { const { field } = useController({ name: 'test', defaultValue: '', }); return ; }; const TestWatch = () => { const value = useWatch({ name: 'test', }); return

{value}

; }; const TestFormState = () => { const { isDirty } = useFormState(); return
{isDirty ? 'yes' : 'no'}
; }; const TestUseFormContext = () => { const methods = useFormContext(); methods.register('test'); return null; }; const Component = () => { const methods = useForm(); return ( ); }; const output = renderToString(); expect(output).toEqual('

no
'); }); });