web 3d图形渲染器
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.

23 lines
1.1 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.toHaveTextContent = toHaveTextContent;
  6. var _utils = require("./utils");
  7. function toHaveTextContent(htmlElement, checkWith, options = {
  8. normalizeWhitespace: true
  9. }) {
  10. (0, _utils.checkHtmlElement)(htmlElement, toHaveTextContent, this);
  11. const textContent = options.normalizeWhitespace ? (0, _utils.normalize)(htmlElement.textContent) : htmlElement.textContent.replace(/\u00a0/g, ' '); // Replace   with normal spaces
  12. const checkingWithEmptyString = textContent !== '' && checkWith === '';
  13. return {
  14. pass: !checkingWithEmptyString && (0, _utils.matches)(textContent, checkWith),
  15. message: () => {
  16. const to = this.isNot ? 'not to' : 'to';
  17. return (0, _utils.getMessage)(this, this.utils.matcherHint(`${this.isNot ? '.not' : ''}.toHaveTextContent`, 'element', ''), checkingWithEmptyString ? `Checking with empty string will always match, use .toBeEmptyDOMElement() instead` : `Expected element ${to} have text content`, checkWith, 'Received', textContent);
  18. }
  19. };
  20. }