UNPKG

@thisisagile/easy-test

Version:

Straightforward library for testing microservices built with @thisisagile/easy

32 lines (31 loc) 1.09 kB
import { checkDefined } from "../chunk-Z4XAP66Q.mjs"; import { match } from "../chunk-LN24S2PC.mjs"; import "../chunk-6EKWTLNQ.mjs"; import { asString } from "../chunk-O475TEG2.mjs"; // src/matchers/toBeRoutedTo.ts var weExpectedButReceivedInstead = ([r, e]) => `We expected ${asString(e)}, but we received '${asString(r)}' instead.`; function toMatchAsString(received, expected) { return checkDefined(this, received, expected).not( ([r, e]) => this.equals(asString(r), asString(e)), ([r, e]) => weExpectedButReceivedInstead([r, e]) ).else(); } var toBeRoutedTo = (query, expected) => match(query?.mock?.calls).undefined((c) => c, "Uri is unknown.").not((c) => c.length === 1, "Method was not called.").not( (c) => asString(c[0][0]) === asString(expected), (c) => `We expected uri '${asString(expected)}', but we received uri '${asString(c[0][0])}' instead.` ).else(`Called uri does match '${asString(expected)}'`); expect.extend({ toBeRoutedTo }); export { toBeRoutedTo, toMatchAsString, weExpectedButReceivedInstead }; //# sourceMappingURL=toBeRoutedTo.mjs.map