// tslint:disable:no-invalid-this import "jest"; import { Mark } from "prosemirror-model"; import { ExpectExtendSync } from "./expect"; const matcherName = "toMatchMark"; const toMatchMark: ExpectExtendSync = function(received, expected) { if (!(expected instanceof Mark)) { return { message: () => `${this.utils.matcherHint(`.${matcherName}`)}\n\n` + `Expected value should be an Mark (using instanceof):\n` + ` ${this.utils.printExpected(expected)}`, pass: false }; } if (!(received instanceof Mark)) { return { message: () => `${this.utils.matcherHint(`.${matcherName}`)}\n\n` + `Received value should be an Mark (using instanceof):\n` + ` ${this.utils.printReceived(received)}`, pass: false }; } const pass = expected.eq(received); return { message: () => pass ? `${this.utils.matcherHint(`.not.${matcherName}`)}\n\n` + `Expected to not be (using .eq):\n` + ` ${this.utils.printExpected(expected)}\n` + `Received:\n` + ` ${this.utils.printReceived(received)}` : `${this.utils.matcherHint(`.${matcherName}`)}\n\n` + `Expected to be (using .eq):\n` + ` ${this.utils.printExpected(expected)}\n` + `Received:\n` + ` ${this.utils.printReceived(received)}`, pass }; }; declare global { namespace jest { interface Matchers { toMatchMark(expected: Mark): R; } } } expect.extend({ toMatchMark });