# All files / src/helpers/matchers accessibilityValue.ts

100% Statements 2/2
100% Branches 10/10
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25

    307x
    307x

     import { AccessibilityValue } from 'react-native';
    import { ReactTestInstance } from 'react-test-renderer';
    import { TextMatch } from '../../matches';
    import { matchStringProp } from './matchStringProp';

    export interface AccessibilityValueMatcher {
      min?: number;
      max?: number;
      now?: number;
      text?: TextMatch;
    }

    export function matchAccessibilityValue(
      node: ReactTestInstance,
      matcher: AccessibilityValueMatcher
    ): boolean {
      const value: AccessibilityValue = node.props.accessibilityValue ?? {};
      return (
        (matcher.min === undefined || matcher.min === value.min) &&
        (matcher.max === undefined || matcher.max === value.max) &&
        (matcher.now === undefined || matcher.now === value.now) &&
        (matcher.text === undefined || matchStringProp(value.text, matcher.text))
      );
    }