@@ -68,6 +68,22 @@ export async function testQueryHelpers() {
68
68
: includesAutomationId ( content , automationId ) ,
69
69
options ,
70
70
)
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
+
71
87
const [
72
88
queryByAutomationId ,
73
89
getAllByAutomationId ,
@@ -76,8 +92,14 @@ export async function testQueryHelpers() {
76
92
findByAutomationId ,
77
93
] = buildQueries (
78
94
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
+ ) ,
81
103
)
82
104
queryByAutomationId ( element , 'id' )
83
105
getAllByAutomationId ( element , 'id' )
@@ -89,6 +111,11 @@ export async function testQueryHelpers() {
89
111
await findByAutomationId ( element , 'id' , { } )
90
112
await findAllByAutomationId ( element , 'id' )
91
113
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' ] )
92
119
}
93
120
94
121
export function testBoundFunctions ( ) {
0 commit comments