You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bindByTextQueries = void 0;
var _filterNodeByType = require("../helpers/filterNodeByType");
var _findAll = require("../helpers/findAll");
var _hostComponentNames = require("../helpers/host-component-names");
var _matchTextContent = require("../helpers/matchers/matchTextContent");
var _makeQueries = require("./makeQueries");
const queryAllByText = instance => function queryAllByTextFn(text, options = {}) {
return (0, _findAll.findAll)(instance, node => (0, _filterNodeByType.filterNodeByType)(node, (0, _hostComponentNames.getHostComponentNames)().text) && (0, _matchTextContent.matchTextContent)(node, text, options), {
...options,
matchDeepestOnly: true
});
};
const getMultipleError = text => `Found multiple elements with text: ${String(text)}`;
const getMissingError = text => `Unable to find an element with text: ${String(text)}`;
const {
getBy,
getAllBy,
queryBy,
queryAllBy,
findBy,
findAllBy
} = (0, _makeQueries.makeQueries)(queryAllByText, getMissingError, getMultipleError);
const bindByTextQueries = instance => ({
getByText: getBy(instance),
getAllByText: getAllBy(instance),
queryByText: queryBy(instance),
queryAllByText: queryAllBy(instance),
findByText: findBy(instance),
findAllByText: findAllBy(instance)
});
exports.bindByTextQueries = bindByTextQueries;
//# sourceMappingURL=text.js.map