Skip to content

Commit 28b0b28

Browse files
committed
fix: add number support for matches
1 parent accb6cc commit 28b0b28

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

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 {

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)