Skip to content

Commit 3723cbe

Browse files
authored
Merge branch 'main' into fix-broken-specs
2 parents 98b8bb3 + 8746d21 commit 3723cbe

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,15 @@
14431443
"contributions": [
14441444
"code"
14451445
]
1446+
},
1447+
{
1448+
"login": "jacklaurencegaray",
1449+
"name": "Jack Laurence",
1450+
"avatar_url": "https://avatars.githubusercontent.com/u/12763356?v=4",
1451+
"profile": "http://www.jacklaurence.net",
1452+
"contributions": [
1453+
"code"
1454+
]
14461455
}
14471456
],
14481457
"repoHost": "https://github.com"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ Thanks goes to these people ([emoji key][emojis]):
320320
<td align="center"><a href="http://www.hawkeye.dog"><img src="https://avatars.githubusercontent.com/u/7245931?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Fleischman</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=istateside" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=istateside" title="Tests">⚠️</a></td>
321321
<td align="center"><a href="http://dfdx.us"><img src="https://avatars.githubusercontent.com/u/3087358?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Beth Hitch</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=dfoverdx" title="Code">💻</a></td>
322322
</tr>
323+
<tr>
324+
<td align="center"><a href="http://www.jacklaurence.net"><img src="https://avatars.githubusercontent.com/u/12763356?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jack Laurence</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=jacklaurencegaray" title="Code">💻</a></td>
325+
</tr>
323326
</table>
324327

325328
<!-- markdownlint-restore -->

types/__tests__/type-tests.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

94121
export function testBoundFunctions() {

types/query-helpers.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ export type BuiltQueryMethods<Arguments extends any[]> = [
6969

7070
export function buildQueries<Arguments extends any[]>(
7171
queryAllBy: GetAllBy<Arguments>,
72-
getMultipleError: GetErrorFunction,
73-
getMissingError: GetErrorFunction,
72+
getMultipleError: GetErrorFunction<Arguments>,
73+
getMissingError: GetErrorFunction<Arguments>,
7474
): BuiltQueryMethods<Arguments>

0 commit comments

Comments
 (0)