@thisisagile/easy-test
Version:
Straightforward library for testing microservices built with @thisisagile/easy
41 lines (39 loc) • 959 B
JavaScript
import {
toMessage
} from "./chunk-6EKWTLNQ.mjs";
import {
isDefined
} from "./chunk-O475TEG2.mjs";
// src/matchers/Match.ts
var Match = class _Match {
constructor(subject, failed = false, message = "") {
this.subject = subject;
this.failed = failed;
this.message = message;
}
not(p, message) {
if (this.failed) {
return this;
}
try {
return new _Match(this.subject, !p(this.subject), toMessage(message, this.subject));
} catch (e) {
return new _Match(this.subject, true, e.message);
}
}
undefined(p, message) {
return this.not(() => isDefined(p(this.subject)), message);
}
else(message) {
return {
pass: !this.failed,
message: () => this.failed ? toMessage(this.message) : `${toMessage(message, this.subject)}, which we did not expect.`
};
}
};
var match = (subject) => new Match(subject);
export {
Match,
match
};
//# sourceMappingURL=chunk-LN24S2PC.mjs.map