@@ -132,6 +132,50 @@ export async function testQueryHelpers() {
132132 screenWithCustomQueries . getByAutomationId ( [ 'id' , 'automationId' ] )
133133 await screenWithCustomQueries . findAllByAutomationId ( 'id' , { } , { timeout : 1000 } )
134134 await screenWithCustomQueries . findByAutomationId ( 'id' , { } , { timeout : 1000 } )
135+
136+ // contrived example of a custom query with no arguments beyond container
137+ function queryAllByFoo ( container : HTMLElement ) {
138+ return queryAllByText ( container , 'Foo' )
139+ }
140+
141+ const [
142+ queryByTextFoo ,
143+ getAllByTextFoo ,
144+ getByTextFoo ,
145+ findAllByTextFoo ,
146+ findByTextFoo ,
147+ ] = buildQueries (
148+ queryAllByFoo ,
149+ createIdRelatedErrorHandler (
150+ `Found multiple elements with text Foo` ,
151+ 'Multiple error' ,
152+ ) ,
153+ createIdRelatedErrorHandler (
154+ `Unable to find an element with text Foo` ,
155+ 'Missing error' ,
156+ ) ,
157+ )
158+
159+ queryByTextFoo ( element )
160+ getAllByTextFoo ( element )
161+ getByTextFoo ( element )
162+ await findAllByTextFoo ( element )
163+ await findByTextFoo ( element )
164+
165+ const screenWithCustomFooQueries = within ( document . body , {
166+ ...queries ,
167+ queryByTextFoo,
168+ getAllByTextFoo,
169+ getByTextFoo,
170+ findAllByTextFoo,
171+ findByTextFoo,
172+ } )
173+
174+ screenWithCustomFooQueries . queryByTextFoo ( )
175+ screenWithCustomFooQueries . getAllByTextFoo ( )
176+ screenWithCustomFooQueries . getByTextFoo ( )
177+ await screenWithCustomFooQueries . findAllByTextFoo ( )
178+ await screenWithCustomFooQueries . findByTextFoo ( )
135179}
136180
137181export function testBoundFunctions ( ) {
0 commit comments