@@ -6,7 +6,7 @@ import Form, { Field, useForm } from '../src';
66import { changeValue , getInput , matchError } from './common' ;
77import InfoField , { Input } from './common/InfoField' ;
88import timeout from './common/timeout' ;
9- import type { Meta } from '@/interface' ;
9+ import type { FormRef , Meta } from '@/interface' ;
1010
1111describe ( 'Form.Basic' , ( ) => {
1212 describe ( 'create form' , ( ) => {
@@ -85,7 +85,7 @@ describe('Form.Basic', () => {
8585 } ) ;
8686
8787 it ( 'fields touched' , async ( ) => {
88- const form = React . createRef < FormInstance > ( ) ;
88+ const form = React . createRef < FormRef > ( ) ;
8989
9090 const { container } = render (
9191 < div >
@@ -111,12 +111,15 @@ describe('Form.Basic', () => {
111111 expect ( form . current ?. isFieldsTouched ( [ 'username' , 'password' ] ) ) . toBeTruthy ( ) ;
112112 expect ( form . current ?. isFieldsTouched ( true ) ) . toBeTruthy ( ) ;
113113 expect ( form . current ?. isFieldsTouched ( [ 'username' , 'password' ] , true ) ) . toBeTruthy ( ) ;
114+
115+ // nativeElementRef
116+ expect ( form . current ?. nativeElement ) . toBeTruthy ( ) ;
114117 } ) ;
115118
116119 describe ( 'reset form' , ( ) => {
117120 function resetTest ( name : string , ...args ) {
118121 it ( name , async ( ) => {
119- const form = React . createRef < FormInstance > ( ) ;
122+ const form = React . createRef < FormRef > ( ) ;
120123 const onReset = jest . fn ( ) ;
121124 const onMeta = jest . fn ( ) ;
122125
@@ -187,7 +190,7 @@ describe('Form.Basic', () => {
187190 resetTest ( 'without field name' ) ;
188191
189192 it ( 'not affect others' , async ( ) => {
190- const form = React . createRef < FormInstance > ( ) ;
193+ const form = React . createRef < FormRef > ( ) ;
191194
192195 const { container } = render (
193196 < div >
@@ -345,7 +348,7 @@ describe('Form.Basic', () => {
345348 it ( 'getInternalHooks should not usable by user' , ( ) => {
346349 const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
347350
348- const form = React . createRef < FormInstance > ( ) ;
351+ const form = React . createRef < FormRef > ( ) ;
349352 render (
350353 < div >
351354 < Form ref = { form } />
@@ -362,7 +365,7 @@ describe('Form.Basic', () => {
362365 } ) ;
363366
364367 it ( 'valuePropName' , async ( ) => {
365- const form = React . createRef < FormInstance > ( ) ;
368+ const form = React . createRef < FormRef > ( ) ;
366369 const { container } = render (
367370 < div >
368371 < Form ref = { form } >
@@ -422,9 +425,7 @@ describe('Form.Basic', () => {
422425 < Field getValueProps = { getValueProps1 } >
423426 < span className = "anything" />
424427 </ Field >
425- < Field getValueProps = { getValueProps2 } >
426- { ( ) => < span className = "anything" /> }
427- </ Field >
428+ < Field getValueProps = { getValueProps2 } > { ( ) => < span className = "anything" /> } </ Field >
428429 </ Form >
429430 </ div > ,
430431 ) ;
@@ -511,7 +512,7 @@ describe('Form.Basic', () => {
511512
512513 describe ( 'setFields' , ( ) => {
513514 it ( 'should work' , ( ) => {
514- const form = React . createRef < FormInstance > ( ) ;
515+ const form = React . createRef < FormRef > ( ) ;
515516 const { container } = render (
516517 < div >
517518 < Form ref = { form } >
@@ -535,7 +536,7 @@ describe('Form.Basic', () => {
535536
536537 it ( 'should trigger by setField' , ( ) => {
537538 const triggerUpdate = jest . fn ( ) ;
538- const formRef = React . createRef < FormInstance > ( ) ;
539+ const formRef = React . createRef < FormRef > ( ) ;
539540
540541 render (
541542 < div >
@@ -596,7 +597,7 @@ describe('Form.Basic', () => {
596597 } ) ;
597598
598599 it ( 'setFieldsValue should clean up status' , async ( ) => {
599- const form = React . createRef < FormInstance > ( ) ;
600+ const form = React . createRef < FormRef > ( ) ;
600601 let currentMeta : Meta = null ;
601602
602603 const { container } = render (
@@ -690,7 +691,7 @@ describe('Form.Basic', () => {
690691 } ) ;
691692
692693 it ( 'filtering fields by meta' , async ( ) => {
693- const form = React . createRef < FormInstance > ( ) ;
694+ const form = React . createRef < FormRef > ( ) ;
694695
695696 const { container } = render (
696697 < div >
@@ -857,7 +858,7 @@ describe('Form.Basic', () => {
857858 } ) ;
858859
859860 it ( 'setFieldValue' , ( ) => {
860- const formRef = React . createRef < FormInstance > ( ) ;
861+ const formRef = React . createRef < FormRef > ( ) ;
861862
862863 const Demo : React . FC = ( ) => (
863864 < Form ref = { formRef } initialValues = { { list : [ 'bamboo' , 'little' , 'light' ] } } >
@@ -894,7 +895,7 @@ describe('Form.Basic', () => {
894895
895896 it ( 'onMetaChange should only trigger when meta changed' , ( ) => {
896897 const onMetaChange = jest . fn ( ) ;
897- const formRef = React . createRef < FormInstance > ( ) ;
898+ const formRef = React . createRef < FormRef > ( ) ;
898899
899900 const Demo : React . FC = ( ) => (
900901 < Form ref = { formRef } >
@@ -920,7 +921,7 @@ describe('Form.Basic', () => {
920921 describe ( 'set to null value' , ( ) => {
921922 function test ( name : string , callback : ( form : FormInstance ) => void ) {
922923 it ( name , async ( ) => {
923- const form = React . createRef < FormInstance > ( ) ;
924+ const form = React . createRef < FormRef > ( ) ;
924925
925926 const { container } = render (
926927 < div >
@@ -953,7 +954,7 @@ describe('Form.Basic', () => {
953954
954955 it ( 'setFieldValue should always set touched' , async ( ) => {
955956 const EMPTY_VALUES = { light : '' , bamboo : [ ] } ;
956- const formRef = React . createRef < FormInstance > ( ) ;
957+ const formRef = React . createRef < FormRef > ( ) ;
957958
958959 const Demo : React . FC = ( ) => (
959960 < Form ref = { formRef } initialValues = { EMPTY_VALUES } >
0 commit comments