Skip to content

Commit 63c7dbe

Browse files
author
MattAgn
committed
refactor: extract matchArrayValue
1 parent b5e6d63 commit 63c7dbe

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export function matchArrayValue(
2+
prop: Array<string> | undefined,
3+
matcher: string | Array<string>
4+
): boolean {
5+
if (!prop || matcher.length === 0) {
6+
return false;
7+
}
8+
9+
if (typeof matcher === 'string') {
10+
return prop.includes(matcher);
11+
}
12+
13+
return !matcher.some((e) => !prop.includes(e));
14+
}

src/queries/a11yStates.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ReactTestInstance } from 'react-test-renderer';
22
import { AccessibilityState } from 'react-native';
3+
import { matchArrayValue } from '../helpers/matchers/matchArrayValue';
34
import { makeQueries } from './makeQueries';
45
import type {
56
FindAllByQuery,
@@ -15,21 +16,6 @@ type AccessibilityStateKeys =
1516
| AccessibilityStateKey
1617
| Array<AccessibilityStateKey>;
1718

18-
export function matchArrayValue(
19-
prop: Array<string> | undefined,
20-
matcher: string | Array<string>
21-
): boolean {
22-
if (!prop || matcher.length === 0) {
23-
return false;
24-
}
25-
26-
if (typeof matcher === 'string') {
27-
return prop.includes(matcher);
28-
}
29-
30-
return !matcher.some((e) => !prop.includes(e));
31-
}
32-
3319
const queryAllByA11yStates = (
3420
instance: ReactTestInstance
3521
): ((

0 commit comments

Comments
 (0)