UNPKG

@thisisagile/easy-test

Version:

Straightforward library for testing microservices built with @thisisagile/easy

16 lines 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toMatchException = void 0; const Match_1 = require("./Match"); const Utils_1 = require("../utils/Utils"); const toMatchException = (received, expected, reason) => (0, Match_1.match)(expected) .undefined(e => e.id, 'Expected value is not an exception.') .not(e => e.id === received.id, e => `Expected exception has id '${e.id}', while the received exception has id '${received.id}'.`) .not(() => !(0, Utils_1.isDefined)(reason) || ((0, Utils_1.isDefined)(reason) && (0, Utils_1.isDefined)(received.reason)), () => `We expected to have reason '${reason}', but we received no reason.`) .not(() => !(0, Utils_1.isDefined)(reason) || ((0, Utils_1.isDefined)(reason) && received.reason === reason), () => `We expected to have reason '${reason}', but we received reason '${received.reason}'.`) .else(`Expected exception matches received exception`); exports.toMatchException = toMatchException; expect.extend({ toMatchException: exports.toMatchException, }); //# sourceMappingURL=toMatchException.js.map