Sha256: bdafe981615f8aca271e56716c7f3d48481c03a494be461748e53c3210130aad

Contents?: true

Size: 2 KB

Versions: 26

Compression:

Stored size: 2 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.queryByDisplayValue = exports.queryAllByDisplayValue = exports.getByDisplayValue = exports.getAllByDisplayValue = exports.findByDisplayValue = exports.findAllByDisplayValue = void 0;
var _queryHelpers = require("../query-helpers");
var _helpers = require("../helpers");
var _allUtils = require("./all-utils");
const queryAllByDisplayValue = (container, value, {
  exact = true,
  collapseWhitespace,
  trim,
  normalizer
} = {}) => {
  (0, _helpers.checkContainerType)(container);
  const matcher = exact ? _allUtils.matches : _allUtils.fuzzyMatches;
  const matchNormalizer = (0, _allUtils.makeNormalizer)({
    collapseWhitespace,
    trim,
    normalizer
  });
  return Array.from(container.querySelectorAll(`input,textarea,select`)).filter(node => {
    if (node.tagName === 'SELECT') {
      const selectedOptions = Array.from(node.options).filter(option => option.selected);
      return selectedOptions.some(optionNode => matcher((0, _allUtils.getNodeText)(optionNode), optionNode, value, matchNormalizer));
    } else {
      return matcher(node.value, node, value, matchNormalizer);
    }
  });
};
const getMultipleError = (c, value) => `Found multiple elements with the display value: ${value}.`;
const getMissingError = (c, value) => `Unable to find an element with the display value: ${value}.`;
const queryAllByDisplayValueWithSuggestions = exports.queryAllByDisplayValue = (0, _queryHelpers.wrapAllByQueryWithSuggestion)(queryAllByDisplayValue, queryAllByDisplayValue.name, 'queryAll');
const [queryByDisplayValue, getAllByDisplayValue, getByDisplayValue, findAllByDisplayValue, findByDisplayValue] = (0, _allUtils.buildQueries)(queryAllByDisplayValue, getMultipleError, getMissingError);
exports.findByDisplayValue = findByDisplayValue;
exports.findAllByDisplayValue = findAllByDisplayValue;
exports.getByDisplayValue = getByDisplayValue;
exports.getAllByDisplayValue = getAllByDisplayValue;
exports.queryByDisplayValue = queryByDisplayValue;

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/@testing-library/dom/dist/queries/display-value.js