@@ -25,13 +25,13 @@ export type QueryAllByQuery<Predicate, Options = void> = (
2525
2626export type FindByQuery < Predicate , Options = void > = (
2727 predicate : Predicate ,
28- options ?: Options & WaitForOptions ,
28+ options ?: Options ,
2929 waitForOptions ?: WaitForOptions
3030) => Promise < ReactTestInstance > ;
3131
3232export type FindAllByQuery < Predicate , Options = void > = (
3333 predicate : Predicate ,
34- options ?: Options & WaitForOptions ,
34+ options ?: Options ,
3535 waitForOptions ?: WaitForOptions
3636) => Promise < ReactTestInstance [ ] > ;
3737
@@ -46,36 +46,6 @@ export type UnboundQueries<Predicate, Options> = {
4646 findAllBy : UnboundQuery < FindAllByQuery < Predicate , Options > > ;
4747} ;
4848
49- // The WaitForOptions has been moved to the second option param of findBy* methods with the adding of TextMatchOptions
50- // To make the migration easier and avoid a breaking change, keep reading this options from the first param but warn
51- const deprecatedKeys : ( keyof WaitForOptions ) [ ] = [
52- 'timeout' ,
53- 'interval' ,
54- 'stackTraceError' ,
55- ] ;
56- const extractDeprecatedWaitForOptionUsage = ( queryOptions ?: WaitForOptions ) => {
57- if ( queryOptions ) {
58- const waitForOptions : WaitForOptions = {
59- timeout : queryOptions . timeout ,
60- interval : queryOptions . interval ,
61- stackTraceError : queryOptions . stackTraceError ,
62- } ;
63- deprecatedKeys . forEach ( ( key ) => {
64- const option = queryOptions [ key ] ;
65- if ( option ) {
66- // eslint-disable-next-line no-console
67- console . warn (
68- `Use of option "${ key } " in a findBy* query's second parameter, TextMatchOptions, is deprecated. Please pass this option in the third, WaitForOptions, parameter.
69- Example:
70-
71- findByText(text, {}, { ${ key } : ${ option . toString ( ) } })`
72- ) ;
73- }
74- } ) ;
75- return waitForOptions ;
76- }
77- } ;
78-
7949export function makeQueries < Predicate , Options > (
8050 queryAllByQuery : UnboundQuery < QueryAllByQuery < Predicate , Options > > ,
8151 getMissingError : ( predicate : Predicate ) => string ,
@@ -128,32 +98,26 @@ export function makeQueries<Predicate, Options>(
12898 function findAllByQuery ( instance : ReactTestInstance ) {
12999 return function findAllFn (
130100 predicate : Predicate ,
131- queryOptions ?: Options & WaitForOptions ,
132- waitForOptions : WaitForOptions = { }
101+ queryOptions ?: Options ,
102+ waitForOptions ? : WaitForOptions
133103 ) {
134- const deprecatedWaitForOptions = extractDeprecatedWaitForOptionUsage (
135- queryOptions
104+ return waitFor (
105+ ( ) => getAllByQuery ( instance ) ( predicate , queryOptions ) ,
106+ waitForOptions
136107 ) ;
137- return waitFor ( ( ) => getAllByQuery ( instance ) ( predicate , queryOptions ) , {
138- ...deprecatedWaitForOptions ,
139- ...waitForOptions ,
140- } ) ;
141108 } ;
142109 }
143110
144111 function findByQuery ( instance : ReactTestInstance ) {
145112 return function findFn (
146113 predicate : Predicate ,
147- queryOptions ?: Options & WaitForOptions ,
148- waitForOptions : WaitForOptions = { }
114+ queryOptions ?: Options ,
115+ waitForOptions ? : WaitForOptions
149116 ) {
150- const deprecatedWaitForOptions = extractDeprecatedWaitForOptionUsage (
151- queryOptions
117+ return waitFor (
118+ ( ) => getByQuery ( instance ) ( predicate , queryOptions ) ,
119+ waitForOptions
152120 ) ;
153- return waitFor ( ( ) => getByQuery ( instance ) ( predicate , queryOptions ) , {
154- ...deprecatedWaitForOptions ,
155- ...waitForOptions ,
156- } ) ;
157121 } ;
158122 }
159123
0 commit comments