UNPKG

@fgv/ts-utils-jest

Version:
29 lines 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const matcherHelpers_1 = require("../../utils/matcherHelpers"); const predicate_1 = require("./predicate"); const jest_matcher_utils_1 = require("jest-matcher-utils"); function passMessage(received, expected) { return () => [ (0, jest_matcher_utils_1.matcherHint)(`.not.${predicate_1.matcherName}`), (0, matcherHelpers_1.printExpectedResult)('failure', false, expected), (0, matcherHelpers_1.printReceivedResult)(received) ].join('\n'); } function failMessage(received, expected) { return () => [ (0, jest_matcher_utils_1.matcherHint)(`${predicate_1.matcherName}`), (0, matcherHelpers_1.printExpectedResult)('failure', true, expected), (0, matcherHelpers_1.printReceivedResult)(received) ].join('\n'); } exports.default = { toFailWith: function (received, expected) { const pass = (0, predicate_1.predicate)(received, expected); if (pass) { return { pass: true, message: passMessage(received, expected) }; } return { pass: false, message: failMessage(received, expected) }; } }; //# sourceMappingURL=index.js.map