Skip to content

Commit a40638c

Browse files
authored
Merge branch 'master' into fix/pass-container-to-wait-for
2 parents f2ca502 + cb70902 commit a40638c

File tree

7 files changed

+164
-137
lines changed

7 files changed

+164
-137
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,16 @@
12911291
"code",
12921292
"test"
12931293
]
1294+
},
1295+
{
1296+
"login": "johnjesse",
1297+
"name": "johnjessewood",
1298+
"avatar_url": "https://avatars1.githubusercontent.com/u/6839660?v=4",
1299+
"profile": "https://github.com/johnjesse",
1300+
"contributions": [
1301+
"bug",
1302+
"code"
1303+
]
12941304
}
12951305
],
12961306
"repoHost": "https://github.com"

README.md

Lines changed: 134 additions & 132 deletions
Large diffs are not rendered by default.

src/__tests__/text-matchers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ cases(
231231
<input id="username" />`,
232232
queryFn: 'queryAllByLabelText',
233233
},
234+
queryAllByAriaLabelText: {
235+
dom: `<div aria-label="User ${LRM}name"/>`,
236+
queryFn: 'queryAllByLabelText',
237+
},
234238
queryAllByPlaceholderText: {
235239
dom: `<input placeholder="User ${LRM}name" />`,
236240
queryFn: 'queryAllByPlaceholderText',

src/matches.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ function fuzzyMatches(
3131

3232
const normalizedText = normalizer(textToMatch)
3333

34-
if (typeof matcher === 'string') {
35-
return normalizedText.toLowerCase().includes(matcher.toLowerCase())
34+
if (typeof matcher === 'string' || typeof matcher === 'number') {
35+
return normalizedText
36+
.toLowerCase()
37+
.includes(matcher.toString().toLowerCase())
3638
} else if (typeof matcher === 'function') {
3739
return matcher(normalizedText, node)
3840
} else {

src/queries/label-text.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ function queryAllByLabelText(
9191

9292
return labelledElements
9393
}, [])
94-
.concat(queryAllByAttribute('aria-label', container, text, {exact}))
94+
.concat(
95+
queryAllByAttribute('aria-label', container, text, {
96+
exact,
97+
normalizer: matchNormalizer,
98+
}),
99+
)
95100

96101
return Array.from(new Set(matchingLabelledElements)).filter(element =>
97102
element.matches(selector),

types/matches.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type MatcherFunction = (
66
content: string,
77
element: Nullish<Element>,
88
) => boolean
9-
export type Matcher = MatcherFunction | RegExp | string
9+
export type Matcher = MatcherFunction | RegExp | string | number
1010

1111
// Get autocomplete for ARIARole union types, while still supporting another string
1212
// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-505826972

types/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"extends": "../tsconfig.json"
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"paths": {"@testing-library/dom": ["."]}
6+
}
37
}

0 commit comments

Comments
 (0)