@@ -68,6 +68,22 @@ export async function testQueryHelpers() {
6868 : includesAutomationId ( content , automationId ) ,
6969 options ,
7070 )
71+
72+ const createIdRelatedErrorHandler =
73+ ( errorMessage : string , defaultErrorMessage : string ) =>
74+ < T > ( container : Element | null , ...args : T [ ] ) => {
75+ const [ key , value ] = args
76+ if ( ! container ) {
77+ return 'Container element not specified'
78+ }
79+ if ( key && value ) {
80+ return errorMessage
81+ . replace ( '[key]' , String ( key ) )
82+ . replace ( '[value]' , String ( value ) )
83+ }
84+ return defaultErrorMessage
85+ }
86+
7187 const [
7288 queryByAutomationId ,
7389 getAllByAutomationId ,
@@ -76,8 +92,14 @@ export async function testQueryHelpers() {
7692 findByAutomationId ,
7793 ] = buildQueries (
7894 queryAllByAutomationId ,
79- ( ) => 'Multiple Error' ,
80- ( ) => 'Missing Error' ,
95+ createIdRelatedErrorHandler (
96+ `Found multiple with key [key] and value [value]` ,
97+ 'Multiple error' ,
98+ ) ,
99+ createIdRelatedErrorHandler (
100+ `Unable to find an element with the [key] attribute of: [value]` ,
101+ 'Missing error' ,
102+ ) ,
81103 )
82104 queryByAutomationId ( element , 'id' )
83105 getAllByAutomationId ( element , 'id' )
@@ -89,6 +111,11 @@ export async function testQueryHelpers() {
89111 await findByAutomationId ( element , 'id' , { } )
90112 await findAllByAutomationId ( element , 'id' )
91113 await findByAutomationId ( element , 'id' )
114+
115+ await findAllByAutomationId ( element , [ 'id' , 'id' ] , { } )
116+ await findByAutomationId ( element , [ 'id' , 'id' ] , { } )
117+ await findAllByAutomationId ( element , [ 'id' , 'id' ] )
118+ await findByAutomationId ( element , [ 'id' , 'id' ] )
92119}
93120
94121export function testBoundFunctions ( ) {
0 commit comments