to-have-focus.js 633 B

123456789101112131415161718
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.toHaveFocus = toHaveFocus;
  6. var _utils = require("./utils");
  7. function toHaveFocus(element) {
  8. (0, _utils.checkHtmlElement)(element, toHaveFocus, this);
  9. return {
  10. pass: element.ownerDocument.activeElement === element,
  11. message: () => {
  12. return [this.utils.matcherHint(`${this.isNot ? '.not' : ''}.toHaveFocus`, 'element', ''), '', 'Expected element with focus:', ` ${this.utils.printExpected(element)}`, 'Received element with focus:', ` ${this.utils.printReceived(element.ownerDocument.activeElement)}`].join('\n');
  13. }
  14. };
  15. }