MCPcopy Index your code
hub / github.com/callstack/react-native-testing-library / toBeChecked

Function toBeChecked

src/matchers/to-be-checked.ts:16–38  ·  view source on GitHub ↗
(this: jest.MatcherContext, instance: TestInstance)

Source from the content-addressed store, hash-verified

14import { checkHostElement } from './utils';
15
16export function toBeChecked(this: jest.MatcherContext, instance: TestInstance) {
17 checkHostElement(instance, toBeChecked, this);
18
19 if (!isHostSwitch(instance) && !isSupportedAccessibilityElement(instance)) {
20 throw new ErrorWithStack(
21 `toBeChecked() works only on host "Switch" instances or accessible instance with "checkbox", "radio" or "switch" role.`,
22 toBeChecked,
23 );
24 }
25
26 return {
27 pass: computeAriaChecked(instance) === true,
28 message: () => {
29 const is = this.isNot ? 'is' : 'is not';
30 return [
31 matcherHint(`${this.isNot ? '.not' : ''}.toBeChecked`, 'instance', ''),
32 '',
33 `Received instance ${is} checked:`,
34 redent(formatElement(instance), 2),
35 ].join('\n');
36 },
37 };
38}
39
40function isSupportedAccessibilityElement(instance: TestInstance) {
41 if (!isAccessibilityElement(instance)) {

Callers

nothing calls this directly

Calls 5

checkHostElementFunction · 0.90
isHostSwitchFunction · 0.90
computeAriaCheckedFunction · 0.90
formatElementFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…