@thisisagile/easy-test 12.13.0 → 12.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ import { Uri } from '../utils/Types';
2
+ export declare const toBeRoutedTo: (query: jest.Mock, expected: Uri) => jest.CustomMatcherResult;
3
+ declare global {
4
+ namespace jest {
5
+ interface Matchers<R, T> {
6
+ toBeRoutedTo(uri: Uri): R;
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBeRoutedTo = void 0;
4
+ const Match_1 = require("./Match");
5
+ const Utils_1 = require("../utils/Utils");
6
+ const toBeRoutedTo = (query, expected) => (0, Match_1.match)(query?.mock?.calls)
7
+ .undefined(c => c, 'Uri is unknown.')
8
+ .not(c => c.length === 1, 'Method was not called.')
9
+ .not(c => (0, Utils_1.asString)(c[0][0]) === (0, Utils_1.asString)(expected), c => `We expected uri '${(0, Utils_1.asString)(expected)}', but we received uri '${(0, Utils_1.asString)(c[0][0])}' instead.`)
10
+ .else(`Called uri does match '${(0, Utils_1.asString)(expected)}'`);
11
+ exports.toBeRoutedTo = toBeRoutedTo;
12
+ expect.extend({
13
+ toBeRoutedTo: exports.toBeRoutedTo,
14
+ });
15
+ //# sourceMappingURL=toBeRoutedTo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toBeRoutedTo.js","sourceRoot":"","sources":["../../src/matchers/toBeRoutedTo.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,0CAA0C;AAEnC,MAAM,YAAY,GAAG,CAAC,KAAgB,EAAE,QAAa,EAA4B,EAAE,CACxF,IAAA,aAAK,EAAQ,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;KAC7B,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,CAAC;KACpC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,wBAAwB,CAAC;KAClD,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAA,gBAAQ,EAAC,QAAQ,CAAC,EAC7C,CAAC,CAAC,EAAE,CAAC,oBAAoB,IAAA,gBAAQ,EAAC,QAAQ,CAAC,2BAA2B,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CACpG;KACA,IAAI,CAAC,0BAA0B,IAAA,gBAAQ,EAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAR9C,QAAA,YAAY,gBAQkC;AAE3D,MAAM,CAAC,MAAM,CAAC;IACZ,YAAY,EAAE,oBAAY;CAC3B,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy-test",
3
- "version": "12.13.0",
3
+ "version": "12.15.0",
4
4
  "description": "Straightforward library for testing microservices built with @thisisagile/easy",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -0,0 +1,26 @@
1
+ import { match } from './Match';
2
+ import { Uri } from '../utils/Types';
3
+ import { asString } from '../utils/Utils';
4
+
5
+ export const toBeRoutedTo = (query: jest.Mock, expected: Uri): jest.CustomMatcherResult =>
6
+ match<any[]>(query?.mock?.calls)
7
+ .undefined(c => c, 'Uri is unknown.')
8
+ .not(c => c.length === 1, 'Method was not called.')
9
+ .not(
10
+ c => asString(c[0][0]) === asString(expected),
11
+ c => `We expected uri '${asString(expected)}', but we received uri '${asString(c[0][0])}' instead.`
12
+ )
13
+ .else(`Called uri does match '${asString(expected)}'`);
14
+
15
+ expect.extend({
16
+ toBeRoutedTo: toBeRoutedTo,
17
+ });
18
+
19
+ declare global {
20
+ // eslint-disable-next-line @typescript-eslint/no-namespace
21
+ namespace jest {
22
+ interface Matchers<R, T> {
23
+ toBeRoutedTo(uri: Uri): R;
24
+ }
25
+ }
26
+ }