@@ -3,12 +3,20 @@ import { useState, useCallback, ReactElement } from 'react';
33import { render , screen , fireEvent , waitFor } from '@testing-library/react' ;
44import expect from 'expect' ;
55
6- import { useReferenceInputController } from './useReferenceInputController' ;
6+ import {
7+ useReferenceInputController ,
8+ UseReferenceInputControllerParams ,
9+ } from './useReferenceInputController' ;
710import { CoreAdminContext } from '../../core' ;
8- import { Form , useInput } from '../../form' ;
11+ import { ChoicesContextValue , Form , useInput } from '../../form' ;
912import { testDataProvider } from '../../dataProvider' ;
13+ import { SortPayload } from '../../types' ;
1014
11- const ReferenceInputController = props => {
15+ const ReferenceInputController = (
16+ props : UseReferenceInputControllerParams & {
17+ children : ( options : ChoicesContextValue ) => React . ReactNode ;
18+ }
19+ ) => {
1220 const { children, ...rest } = props ;
1321 const inputProps = useInput ( {
1422 ...rest ,
@@ -160,7 +168,6 @@ describe('useReferenceInputController', () => {
160168 < Form defaultValues = { { post_id : 1 } } >
161169 < ReferenceInputController
162170 { ...defaultProps }
163- loading
164171 sort = { { field : 'title' , order : 'ASC' } }
165172 >
166173 { children }
@@ -210,7 +217,10 @@ describe('useReferenceInputController', () => {
210217 it ( 'should refetch reference getList when its props change' , async ( ) => {
211218 const children = jest . fn ( ) . mockReturnValue ( < p > child</ p > ) ;
212219 const Component = ( ) => {
213- const [ sort , setSort ] = useState ( { field : 'title' , order : 'ASC' } ) ;
220+ const [ sort , setSort ] = useState < SortPayload > ( {
221+ field : 'title' ,
222+ order : 'ASC' ,
223+ } ) ;
214224 const handleClick = useCallback (
215225 ( ) => setSort ( { field : 'body' , order : 'DESC' } ) ,
216226 [ setSort ]
0 commit comments