@thisisagile/easy-test
Version:
Straightforward library for testing microservices built with @thisisagile/easy
31 lines (30 loc) • 1.28 kB
JavaScript
import {
match
} from "../chunk-LN24S2PC.mjs";
import "../chunk-6EKWTLNQ.mjs";
import "../chunk-O475TEG2.mjs";
// src/matchers/ResultMatchers.ts
var notDefined = "Results is not defined.";
var doesNotFail = "Results does not fail.";
var hasMessage = (res, message) => res.results.some((r) => r.message === message);
var messages = (res) => "'" + res?.results.map((r) => r.message).join("', '") + "'";
var toResultWith = (results, message) => match(results).undefined((r) => r, notDefined).not(
(r) => hasMessage(r, message),
(r) => `Results does not have message '${message}', but it has messages ${messages(r)} instead.`
).else(`Succeeds with message ${message}`);
var toFail = (results) => match(results).undefined((r) => r, notDefined).not((r) => !r.isValid, doesNotFail).else("Results does not fail");
var toFailWith = (results, message) => match(results).undefined((r) => r, notDefined).not((r) => !r.isValid, doesNotFail).not(
(r) => hasMessage(r, message),
(r) => `Fails, but results does not have message '${message}', but it has messages ${messages(r)} instead.`
).else(`Fails with message '${message}'`);
expect.extend({
toResultWith,
toFail,
toFailWith
});
export {
toFail,
toFailWith,
toResultWith
};
//# sourceMappingURL=ResultMatchers.mjs.map