@testing-library/react-native
Version:
Simple and complete React Native testing utilities that encourage good testing practices.
26 lines (25 loc) • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toHaveDisplayValue = toHaveDisplayValue;
var _jestMatcherUtils = require("jest-matcher-utils");
var _errors = require("../helpers/errors");
var _hostComponentNames = require("../helpers/host-component-names");
var _textInput = require("../helpers/text-input");
var _matches = require("../matches");
var _utils = require("./utils");
function toHaveDisplayValue(instance, expectedValue, options) {
(0, _utils.checkHostElement)(instance, toHaveDisplayValue, this);
if (!(0, _hostComponentNames.isHostTextInput)(instance)) {
throw new _errors.ErrorWithStack(`toHaveDisplayValue() works only with host "TextInput" instances. Passed instance has type "${instance.type}".`, toHaveDisplayValue);
}
const receivedValue = (0, _textInput.getTextInputValue)(instance);
return {
pass: (0, _matches.matches)(expectedValue, receivedValue, options?.normalizer, options?.exact),
message: () => {
return [(0, _utils.formatMessage)((0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveDisplayValue`, 'instance', ''), `Expected instance ${this.isNot ? 'not to' : 'to'} have display value`, expectedValue, 'Received', receivedValue)].join('\n');
}
};
}
//# sourceMappingURL=to-have-display-value.js.map