@@ -25,13 +25,13 @@ export type QueryAllByQuery<Predicate, Options = void> = (
25
25
26
26
export type FindByQuery < Predicate , Options = void > = (
27
27
predicate : Predicate ,
28
- options ?: Options & WaitForOptions ,
28
+ options ?: Options ,
29
29
waitForOptions ?: WaitForOptions
30
30
) => Promise < ReactTestInstance > ;
31
31
32
32
export type FindAllByQuery < Predicate , Options = void > = (
33
33
predicate : Predicate ,
34
- options ?: Options & WaitForOptions ,
34
+ options ?: Options ,
35
35
waitForOptions ?: WaitForOptions
36
36
) => Promise < ReactTestInstance [ ] > ;
37
37
@@ -46,36 +46,6 @@ export type UnboundQueries<Predicate, Options> = {
46
46
findAllBy : UnboundQuery < FindAllByQuery < Predicate , Options > > ;
47
47
} ;
48
48
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
-
79
49
export function makeQueries < Predicate , Options > (
80
50
queryAllByQuery : UnboundQuery < QueryAllByQuery < Predicate , Options > > ,
81
51
getMissingError : ( predicate : Predicate ) => string ,
@@ -128,32 +98,26 @@ export function makeQueries<Predicate, Options>(
128
98
function findAllByQuery ( instance : ReactTestInstance ) {
129
99
return function findAllFn (
130
100
predicate : Predicate ,
131
- queryOptions ?: Options & WaitForOptions ,
132
- waitForOptions : WaitForOptions = { }
101
+ queryOptions ?: Options ,
102
+ waitForOptions ? : WaitForOptions
133
103
) {
134
- const deprecatedWaitForOptions = extractDeprecatedWaitForOptionUsage (
135
- queryOptions
104
+ return waitFor (
105
+ ( ) => getAllByQuery ( instance ) ( predicate , queryOptions ) ,
106
+ waitForOptions
136
107
) ;
137
- return waitFor ( ( ) => getAllByQuery ( instance ) ( predicate , queryOptions ) , {
138
- ...deprecatedWaitForOptions ,
139
- ...waitForOptions ,
140
- } ) ;
141
108
} ;
142
109
}
143
110
144
111
function findByQuery ( instance : ReactTestInstance ) {
145
112
return function findFn (
146
113
predicate : Predicate ,
147
- queryOptions ?: Options & WaitForOptions ,
148
- waitForOptions : WaitForOptions = { }
114
+ queryOptions ?: Options ,
115
+ waitForOptions ? : WaitForOptions
149
116
) {
150
- const deprecatedWaitForOptions = extractDeprecatedWaitForOptionUsage (
151
- queryOptions
117
+ return waitFor (
118
+ ( ) => getByQuery ( instance ) ( predicate , queryOptions ) ,
119
+ waitForOptions
152
120
) ;
153
- return waitFor ( ( ) => getByQuery ( instance ) ( predicate , queryOptions ) , {
154
- ...deprecatedWaitForOptions ,
155
- ...waitForOptions ,
156
- } ) ;
157
121
} ;
158
122
}
159
123
0 commit comments