@@ -136,48 +136,53 @@ export function getQueriesForElement<T>(
136
136
) : T & IQueryUtils & IScopedQueryUtils {
137
137
const o = object as any
138
138
if ( ! contextFn ) contextFn = ( ) => o
139
- o . getQueriesForElement = ( ) => getQueriesForElement ( o , ( ) => o )
140
139
141
- o . queryByPlaceholderText = createDelegateFor ( 'queryByPlaceholderText' , contextFn )
142
- o . queryAllByPlaceholderText = createDelegateFor ( 'queryAllByPlaceholderText' , contextFn )
143
- o . getByPlaceholderText = createDelegateFor ( 'getByPlaceholderText' , contextFn )
144
- o . getAllByPlaceholderText = createDelegateFor ( 'getAllByPlaceholderText' , contextFn )
145
-
146
- o . queryByText = createDelegateFor ( 'queryByText' , contextFn )
147
- o . queryAllByText = createDelegateFor ( 'queryAllByText' , contextFn )
148
- o . getByText = createDelegateFor ( 'getByText' , contextFn )
149
- o . getAllByText = createDelegateFor ( 'getAllByText' , contextFn )
150
-
151
- o . queryByLabelText = createDelegateFor ( 'queryByLabelText' , contextFn )
152
- o . queryAllByLabelText = createDelegateFor ( 'queryAllByLabelText' , contextFn )
153
- o . getByLabelText = createDelegateFor ( 'getByLabelText' , contextFn )
154
- o . getAllByLabelText = createDelegateFor ( 'getAllByLabelText' , contextFn )
155
-
156
- o . queryByAltText = createDelegateFor ( 'queryByAltText' , contextFn )
157
- o . queryAllByAltText = createDelegateFor ( 'queryAllByAltText' , contextFn )
158
- o . getByAltText = createDelegateFor ( 'getByAltText' , contextFn )
159
- o . getAllByAltText = createDelegateFor ( 'getAllByAltText' , contextFn )
160
-
161
- o . queryByTestId = createDelegateFor ( 'queryByTestId' , contextFn )
162
- o . queryAllByTestId = createDelegateFor ( 'queryAllByTestId' , contextFn )
163
- o . getByTestId = createDelegateFor ( 'getByTestId' , contextFn )
164
- o . getAllByTestId = createDelegateFor ( 'getAllByTestId' , contextFn )
165
-
166
- o . queryByTitle = createDelegateFor ( 'queryByTitle' , contextFn )
167
- o . queryAllByTitle = createDelegateFor ( 'queryAllByTitle' , contextFn )
168
- o . getByTitle = createDelegateFor ( 'getByTitle' , contextFn )
169
- o . getAllByTitle = createDelegateFor ( 'getAllByTitle' , contextFn )
170
-
171
- o . queryByRole = createDelegateFor ( 'queryByRole' , contextFn )
172
- o . queryAllByRole = createDelegateFor ( 'queryAllByRole' , contextFn )
173
- o . getByRole = createDelegateFor ( 'getByRole' , contextFn )
174
- o . getAllByRole = createDelegateFor ( 'getAllByRole' , contextFn )
175
-
176
- o . queryByDisplayValue = createDelegateFor ( 'queryByDisplayValue' , contextFn )
177
- o . queryAllByDisplayValue = createDelegateFor ( 'queryAllByDisplayValue' , contextFn )
178
- o . getByDisplayValue = createDelegateFor ( 'getByDisplayValue' , contextFn )
179
- o . getAllByDisplayValue = createDelegateFor ( 'getAllByDisplayValue' , contextFn )
140
+ const functionNames : Array < keyof IQueryUtils > = [
141
+ 'queryByPlaceholderText' ,
142
+ 'queryAllByPlaceholderText' ,
143
+ 'getByPlaceholderText' ,
144
+ 'getAllByPlaceholderText' ,
145
+
146
+ 'queryByText' ,
147
+ 'queryAllByText' ,
148
+ 'getByText' ,
149
+ 'getAllByText' ,
150
+
151
+ 'queryByLabelText' ,
152
+ 'queryAllByLabelText' ,
153
+ 'getByLabelText' ,
154
+ 'getAllByLabelText' ,
155
+
156
+ 'queryByAltText' ,
157
+ 'queryAllByAltText' ,
158
+ 'getByAltText' ,
159
+ 'getAllByAltText' ,
160
+
161
+ 'queryByTestId' ,
162
+ 'queryAllByTestId' ,
163
+ 'getByTestId' ,
164
+ 'getAllByTestId' ,
165
+
166
+ 'queryByTitle' ,
167
+ 'queryAllByTitle' ,
168
+ 'getByTitle' ,
169
+ 'getAllByTitle' ,
170
+
171
+ 'queryByRole' ,
172
+ 'queryAllByRole' ,
173
+ 'getByRole' ,
174
+ 'getAllByRole' ,
175
+
176
+ 'queryByDisplayValue' ,
177
+ 'queryAllByDisplayValue' ,
178
+ 'getByDisplayValue' ,
179
+ 'getAllByDisplayValue' ,
180
+ ]
181
+ functionNames . forEach ( functionName => {
182
+ o [ functionName ] = createDelegateFor ( functionName , contextFn )
183
+ } )
180
184
185
+ o . getQueriesForElement = ( ) => getQueriesForElement ( o , ( ) => o )
181
186
o . getNodeText = createDelegateFor < string > ( 'getNodeText' , contextFn , processNodeText )
182
187
183
188
return o
0 commit comments