Skip to content

Commit 7396c8f

Browse files
committed
test(matchers/to-be-checked): validate toBeChecked matcher checks element checked state
1 parent a1d5387 commit 7396c8f

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/__tests__/render-hook.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as React from 'react';
2-
31
import { renderHook } from '..';
42

53
it('renders a hook with initial props and allows rerendering with new props', async () => {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as React from 'react';
2+
import { Text, View } from 'react-native';
3+
4+
import { render, screen } from '../..';
5+
6+
it('checks if element is checked via accessibilityState', async () => {
7+
const Component = () => (
8+
<View>
9+
<View
10+
testID="checked-checkbox"
11+
accessible
12+
role="checkbox"
13+
accessibilityState={{ checked: true }}
14+
/>
15+
<View
16+
testID="unchecked-checkbox"
17+
accessible
18+
role="checkbox"
19+
accessibilityState={{ checked: false }}
20+
/>
21+
</View>
22+
);
23+
24+
await render(<Component />);
25+
26+
const checkedElement = screen.getByTestId('checked-checkbox');
27+
const uncheckedElement = screen.getByTestId('unchecked-checkbox');
28+
29+
expect(checkedElement).toBeChecked();
30+
expect(uncheckedElement).not.toBeChecked();
31+
});

test-coverage-progress.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ test(matchers/to-be-busy): Validates toBeBusy matcher checks if element is busy
2424
test(matchers/to-have-text-content): Validates toHaveTextContent matcher checks if element has expected text content - critical matcher users depend on for verifying text content in components. Coverage: 69.69% statements (was 27.27%), 33.33% branches, 50% functions for to-have-text-content.ts. Covered main matcher function, text content retrieval and matching. Uncovered: error message formatting (lines 22-31).
2525
test(wait-for): Validates waitFor onTimeout callback customizes timeout error messages - critical feature users depend on for customizing error messages when async conditions timeout. Coverage: 67.5% statements (was 65%), 71.42% branches (was 68.96%), 100% functions for wait-for.ts. Covered onTimeout callback invocation and error replacement (lines 184-188). Uncovered: type checking (lines 33-34), fake timers path (lines 47-95), timer switching errors (lines 121-127), non-Error to Error conversion (lines 171-172).
2626
test(matchers/to-be-empty-element): Validates toBeEmptyElement matcher checks if element has no host element children - critical matcher users depend on for testing empty states, loading states, and components that should render nothing. Coverage: 73.07% statements (was 34.61%), 100% branches, 50% functions for to-be-empty-element.ts. Covered main matcher function, children filtering logic, both positive and negative (.not) variants. Uncovered: error message formatting (lines 18-24).
27+
test(matchers/to-be-checked): Validates toBeChecked matcher checks if element is checked via accessibilityState - critical matcher users depend on for testing checkbox/radio button states in forms and interactive components. Coverage: 68.08% statements (was 36.17%), 50% branches, 66.66% functions for to-be-checked.ts. Covered main matcher function, computeAriaChecked logic, checked and unchecked states, both positive and negative (.not) variants. Uncovered: error path for unsupported elements (lines 20-24), error message formatting (lines 29-36), helper function edge case (lines 42-43).

0 commit comments

Comments
 (0)