to-contain-element.js 840 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.toContainElement = toContainElement;
  6. var _utils = require("./utils");
  7. function toContainElement(container, element) {
  8. (0, _utils.checkHtmlElement)(container, toContainElement, this);
  9. if (element !== null) {
  10. (0, _utils.checkHtmlElement)(element, toContainElement, this);
  11. }
  12. return {
  13. pass: container.contains(element),
  14. message: () => {
  15. return [this.utils.matcherHint(`${this.isNot ? '.not' : ''}.toContainElement`, 'element', 'element'), '', // eslint-disable-next-line babel/new-cap
  16. this.utils.RECEIVED_COLOR(`${this.utils.stringify(container.cloneNode(false))} ${this.isNot ? 'contains:' : 'does not contain:'} ${this.utils.stringify(element ? element.cloneNode(false) : element)}
  17. `)].join('\n');
  18. }
  19. };
  20. }