Skip to content

Commit 1d3831e

Browse files
committed
refactor: clean up
1 parent 7cdf2e7 commit 1d3831e

File tree

2 files changed

+10
-48
lines changed

2 files changed

+10
-48
lines changed

src/helpers/accessiblity.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,6 @@ export function getAccessibilityValue(
216216
export function isElementBusy(
217217
element: ReactTestInstance
218218
): NonNullable<AccessibilityState['busy']> {
219-
if (!isAccessibilityElement(element)) {
220-
return false;
221-
}
222-
223219
const { accessibilityState, 'aria-busy': ariaBusy } = element.props;
224220
return ariaBusy ?? accessibilityState?.busy ?? false;
225221
}

src/matchers/__tests__/to-be-busy.test.tsx

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import '../extend-expect';
66
test('toBeBusy() basic case', () => {
77
render(
88
<>
9-
<View testID="busy" accessible accessibilityState={{ busy: true }} />
10-
<View testID="busy-aria" accessible aria-busy />
11-
<View testID="not-busy" accessible accessibilityState={{ busy: false }} />
12-
<View testID="not-busy-aria" accessible aria-busy={false} />
13-
<View testID="default" accessible />
9+
<View testID="busy" accessibilityState={{ busy: true }} />
10+
<View testID="busy-aria" aria-busy />
11+
<View testID="not-busy" accessibilityState={{ busy: false }} />
12+
<View testID="not-busy-aria" aria-busy={false} />
13+
<View testID="default" />
1414
</>
1515
);
1616

@@ -24,11 +24,11 @@ test('toBeBusy() basic case', () => {
2424
test('toBeBusy() error messages', () => {
2525
render(
2626
<>
27-
<View testID="busy" accessible accessibilityState={{ busy: true }} />
28-
<View testID="busy-aria" accessible aria-busy />
29-
<View testID="not-busy" accessible accessibilityState={{ busy: false }} />
30-
<View testID="not-busy-aria" accessible aria-busy={false} />
31-
<View testID="default" accessible />
27+
<View testID="busy" accessibilityState={{ busy: true }} />
28+
<View testID="busy-aria" aria-busy />
29+
<View testID="not-busy" accessibilityState={{ busy: false }} />
30+
<View testID="not-busy-aria" aria-busy={false} />
31+
<View testID="default" />
3232
</>
3333
);
3434

@@ -43,7 +43,6 @@ test('toBeBusy() error messages', () => {
4343
"busy": true,
4444
}
4545
}
46-
accessible={true}
4746
testID="busy"
4847
/>"
4948
`);
@@ -54,7 +53,6 @@ test('toBeBusy() error messages', () => {
5453
5554
Received element is busy:
5655
<View
57-
accessible={true}
5856
aria-busy={true}
5957
testID="busy-aria"
6058
/>"
@@ -71,7 +69,6 @@ test('toBeBusy() error messages', () => {
7169
"busy": false,
7270
}
7371
}
74-
accessible={true}
7572
testID="not-busy"
7673
/>"
7774
`);
@@ -82,7 +79,6 @@ test('toBeBusy() error messages', () => {
8279
8380
Received element is not busy:
8481
<View
85-
accessible={true}
8682
aria-busy={false}
8783
testID="not-busy-aria"
8884
/>"
@@ -94,37 +90,7 @@ test('toBeBusy() error messages', () => {
9490
9591
Received element is not busy:
9692
<View
97-
accessible={true}
9893
testID="default"
9994
/>"
10095
`);
10196
});
102-
103-
test('toBeBusy() requires accessibility elements', () => {
104-
render(
105-
<>
106-
<View testID="busy-aria" aria-busy />
107-
<View testID="not-busy-aria" aria-busy={false} />
108-
<View testID="default" />
109-
</>
110-
);
111-
112-
expect(() => expect(screen.getByTestId('busy-aria')).toBeBusy())
113-
.toThrowErrorMatchingInlineSnapshot(`
114-
"expect(element).toBeBusy()
115-
116-
Received element is not busy:
117-
<View
118-
aria-busy={true}
119-
testID="busy-aria"
120-
/>"
121-
`);
122-
123-
expect(() =>
124-
expect(screen.getByTestId('not-busy-aria')).not.toBeBusy()
125-
).toThrowErrorMatchingInlineSnapshot();
126-
127-
expect(() =>
128-
expect(screen.getByTestId('default')).not.toBeBusy()
129-
).toThrowErrorMatchingInlineSnapshot();
130-
});

0 commit comments

Comments
 (0)