@testing-library/react-native
Version:
Simple and complete React Native testing utilities that encourage good testing practices.
23 lines (22 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toHaveAccessibilityValue = toHaveAccessibilityValue;
var _jestMatcherUtils = require("jest-matcher-utils");
var _accessibility = require("../helpers/accessibility");
var _matchAccessibilityValue = require("../helpers/matchers/match-accessibility-value");
var _object = require("../helpers/object");
var _utils = require("./utils");
function toHaveAccessibilityValue(instance, expectedValue) {
(0, _utils.checkHostElement)(instance, toHaveAccessibilityValue, this);
const receivedValue = (0, _accessibility.computeAriaValue)(instance);
return {
pass: (0, _matchAccessibilityValue.matchAccessibilityValue)(instance, expectedValue),
message: () => {
const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveAccessibilityValue`, 'instance', (0, _jestMatcherUtils.stringify)(expectedValue));
return (0, _utils.formatMessage)(matcher, `Expected the instance ${this.isNot ? 'not to' : 'to'} have accessibility value`, (0, _jestMatcherUtils.stringify)(expectedValue), 'Received instance with accessibility value', (0, _jestMatcherUtils.stringify)((0, _object.removeUndefinedKeys)(receivedValue)));
}
};
}
//# sourceMappingURL=to-have-accessibility-value.js.map