@thisisagile/easy-test 15.12.8 → 15.12.12
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.
- package/dist/matchers/toBeRoutedTo.d.ts +4 -1
- package/dist/matchers/toBeRoutedTo.js +12 -3
- package/dist/matchers/toBeRoutedTo.js.map +1 -1
- package/dist/matchers/toBeRoutedTo.mjs +9 -2
- package/dist/matchers/toBeRoutedTo.mjs.map +1 -1
- package/package.json +1 -1
- package/src/matchers/toBeRoutedTo.ts +21 -4
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { Uri } from "../utils/Types";
|
|
3
|
+
export declare const weExpectedButReceivedInstead: ([r, e]: [any, any]) => string;
|
|
4
|
+
export declare function toMatchAsString(this: jest.MatcherContext, received: unknown, expected: unknown): jest.CustomMatcherResult;
|
|
2
5
|
export declare const toBeRoutedTo: (query: jest.Mock, expected: Uri) => jest.CustomMatcherResult;
|
|
3
6
|
declare global {
|
|
4
7
|
namespace jest {
|
|
@@ -18,11 +18,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var toBeRoutedTo_exports = {};
|
|
20
20
|
__export(toBeRoutedTo_exports, {
|
|
21
|
-
toBeRoutedTo: () => toBeRoutedTo
|
|
21
|
+
toBeRoutedTo: () => toBeRoutedTo,
|
|
22
|
+
toMatchAsString: () => toMatchAsString,
|
|
23
|
+
weExpectedButReceivedInstead: () => weExpectedButReceivedInstead
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(toBeRoutedTo_exports);
|
|
24
|
-
var
|
|
26
|
+
var import_Check = require("./Check");
|
|
25
27
|
var import_Utils = require("../utils/Utils");
|
|
28
|
+
var import_Match = require("./Match");
|
|
29
|
+
const weExpectedButReceivedInstead = ([r, e]) => `We expected ${(0, import_Utils.asString)(e)}, but we received '${(0, import_Utils.asString)(r)}' instead.`;
|
|
30
|
+
function toMatchAsString(received, expected) {
|
|
31
|
+
return (0, import_Check.checkDefined)(this, received, expected).not(([r, e]) => this.equals((0, import_Utils.asString)(r), (0, import_Utils.asString)(e)), ([r, e]) => weExpectedButReceivedInstead([r, e])).else();
|
|
32
|
+
}
|
|
26
33
|
const toBeRoutedTo = (query, expected) => (0, import_Match.match)(query?.mock?.calls).undefined((c) => c, "Uri is unknown.").not((c) => c.length === 1, "Method was not called.").not(
|
|
27
34
|
(c) => (0, import_Utils.asString)(c[0][0]) === (0, import_Utils.asString)(expected),
|
|
28
35
|
(c) => `We expected uri '${(0, import_Utils.asString)(expected)}', but we received uri '${(0, import_Utils.asString)(c[0][0])}' instead.`
|
|
@@ -32,6 +39,8 @@ expect.extend({
|
|
|
32
39
|
});
|
|
33
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
41
|
0 && (module.exports = {
|
|
35
|
-
toBeRoutedTo
|
|
42
|
+
toBeRoutedTo,
|
|
43
|
+
toMatchAsString,
|
|
44
|
+
weExpectedButReceivedInstead
|
|
36
45
|
});
|
|
37
46
|
//# sourceMappingURL=toBeRoutedTo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toBeRoutedTo.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toBeRoutedTo.ts"],"sourcesContent":["import { checkDefined } from \"./Check\";\nimport { Uri } from \"../utils/Types\";\nimport { asString } from \"../utils/Utils\";\nimport { match } from \"./Match\";\n\nexport const weExpectedButReceivedInstead = ([r, e]: [any, any]) => `We expected ${asString(e)}, but we received '${asString(r)}' instead.`;\n\nexport function toMatchAsString(this: jest.MatcherContext, received: unknown, expected: unknown): jest.CustomMatcherResult {\n return checkDefined(this, received, expected)\n .not(([r, e]) => this.equals(asString(r), asString(e)), ([r, e]) => weExpectedButReceivedInstead([r, e]))\n .else();\n}\n\n// export function toBeRoutedTo(this: jest.MatcherContext, query: jest.Mock, expected: Uri): jest.CustomMatcherResult {\n// return check<any[]>(this, query?.mock?.calls)\n// .undefined(r => r, \"Uri is unknown.\")\n// .not(r => r.length === 1, \"Method was not called.\")\n// .not(r => this.equals(asString(r[0][0]), asString(expected)), ([r,e]) => weExpectedButReceivedInstead([r[0][0], e]))\n// .else();\n// }\n\nexport const toBeRoutedTo = (query: jest.Mock, expected: Uri): jest.CustomMatcherResult =>\n match<any[]>(query?.mock?.calls)\n .undefined(c => c, 'Uri is unknown.')\n .not(c => c.length === 1, 'Method was not called.')\n .not(\n c => asString(c[0][0]) === asString(expected),\n c => `We expected uri '${asString(expected)}', but we received uri '${asString(c[0][0])}' instead.`\n )\n .else(`Called uri does match '${asString(expected)}'`);\n\nexpect.extend({\n toBeRoutedTo: toBeRoutedTo\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeRoutedTo(uri: Uri): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6B;AAE7B,mBAAyB;AACzB,mBAAsB;AAEf,MAAM,+BAA+B,CAAC,CAAC,GAAG,CAAC,MAAkB,mBAAe,uBAAS,CAAC,CAAC,0BAAsB,uBAAS,CAAC,CAAC;AAExH,SAAS,gBAA2C,UAAmB,UAA6C;AACzH,aAAO,2BAAa,MAAM,UAAU,QAAQ,EACzC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,WAAO,uBAAS,CAAC,OAAG,uBAAS,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,6BAA6B,CAAC,GAAG,CAAC,CAAC,CAAC,EACvG,KAAK;AACV;AAUO,MAAM,eAAe,CAAC,OAAkB,iBAC7C,oBAAa,OAAO,MAAM,KAAK,EAC5B,UAAU,OAAK,GAAG,iBAAiB,EACnC,IAAI,OAAK,EAAE,WAAW,GAAG,wBAAwB,EACjD;AAAA,EACC,WAAK,uBAAS,EAAE,CAAC,EAAE,CAAC,CAAC,UAAM,uBAAS,QAAQ;AAAA,EAC5C,OAAK,wBAAoB,uBAAS,QAAQ,CAAC,+BAA2B,uBAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzF,EACC,KAAK,8BAA0B,uBAAS,QAAQ,CAAC,GAAG;AAEzD,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { checkDefined } from "./Check";
|
|
2
2
|
import { asString } from "../utils/Utils";
|
|
3
|
+
import { match } from "./Match";
|
|
4
|
+
const weExpectedButReceivedInstead = ([r, e]) => `We expected ${asString(e)}, but we received '${asString(r)}' instead.`;
|
|
5
|
+
function toMatchAsString(received, expected) {
|
|
6
|
+
return checkDefined(this, received, expected).not(([r, e]) => this.equals(asString(r), asString(e)), ([r, e]) => weExpectedButReceivedInstead([r, e])).else();
|
|
7
|
+
}
|
|
3
8
|
const toBeRoutedTo = (query, expected) => match(query?.mock?.calls).undefined((c) => c, "Uri is unknown.").not((c) => c.length === 1, "Method was not called.").not(
|
|
4
9
|
(c) => asString(c[0][0]) === asString(expected),
|
|
5
10
|
(c) => `We expected uri '${asString(expected)}', but we received uri '${asString(c[0][0])}' instead.`
|
|
@@ -8,6 +13,8 @@ expect.extend({
|
|
|
8
13
|
toBeRoutedTo
|
|
9
14
|
});
|
|
10
15
|
export {
|
|
11
|
-
toBeRoutedTo
|
|
16
|
+
toBeRoutedTo,
|
|
17
|
+
toMatchAsString,
|
|
18
|
+
weExpectedButReceivedInstead
|
|
12
19
|
};
|
|
13
20
|
//# sourceMappingURL=toBeRoutedTo.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toBeRoutedTo.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toBeRoutedTo.ts"],"sourcesContent":["import { checkDefined } from \"./Check\";\nimport { Uri } from \"../utils/Types\";\nimport { asString } from \"../utils/Utils\";\nimport { match } from \"./Match\";\n\nexport const weExpectedButReceivedInstead = ([r, e]: [any, any]) => `We expected ${asString(e)}, but we received '${asString(r)}' instead.`;\n\nexport function toMatchAsString(this: jest.MatcherContext, received: unknown, expected: unknown): jest.CustomMatcherResult {\n return checkDefined(this, received, expected)\n .not(([r, e]) => this.equals(asString(r), asString(e)), ([r, e]) => weExpectedButReceivedInstead([r, e]))\n .else();\n}\n\n// export function toBeRoutedTo(this: jest.MatcherContext, query: jest.Mock, expected: Uri): jest.CustomMatcherResult {\n// return check<any[]>(this, query?.mock?.calls)\n// .undefined(r => r, \"Uri is unknown.\")\n// .not(r => r.length === 1, \"Method was not called.\")\n// .not(r => this.equals(asString(r[0][0]), asString(expected)), ([r,e]) => weExpectedButReceivedInstead([r[0][0], e]))\n// .else();\n// }\n\nexport const toBeRoutedTo = (query: jest.Mock, expected: Uri): jest.CustomMatcherResult =>\n match<any[]>(query?.mock?.calls)\n .undefined(c => c, 'Uri is unknown.')\n .not(c => c.length === 1, 'Method was not called.')\n .not(\n c => asString(c[0][0]) === asString(expected),\n c => `We expected uri '${asString(expected)}', but we received uri '${asString(c[0][0])}' instead.`\n )\n .else(`Called uri does match '${asString(expected)}'`);\n\nexpect.extend({\n toBeRoutedTo: toBeRoutedTo\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeRoutedTo(uri: Uri): R;\n }\n }\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAEf,MAAM,+BAA+B,CAAC,CAAC,GAAG,CAAC,MAAkB,eAAe,SAAS,CAAC,CAAC,sBAAsB,SAAS,CAAC,CAAC;AAExH,SAAS,gBAA2C,UAAmB,UAA6C;AACzH,SAAO,aAAa,MAAM,UAAU,QAAQ,EACzC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,OAAO,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,6BAA6B,CAAC,GAAG,CAAC,CAAC,CAAC,EACvG,KAAK;AACV;AAUO,MAAM,eAAe,CAAC,OAAkB,aAC7C,MAAa,OAAO,MAAM,KAAK,EAC5B,UAAU,OAAK,GAAG,iBAAiB,EACnC,IAAI,OAAK,EAAE,WAAW,GAAG,wBAAwB,EACjD;AAAA,EACC,OAAK,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,SAAS,QAAQ;AAAA,EAC5C,OAAK,oBAAoB,SAAS,QAAQ,CAAC,2BAA2B,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzF,EACC,KAAK,0BAA0B,SAAS,QAAQ,CAAC,GAAG;AAEzD,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Uri } from
|
|
3
|
-
import { asString } from
|
|
1
|
+
import { checkDefined } from "./Check";
|
|
2
|
+
import { Uri } from "../utils/Types";
|
|
3
|
+
import { asString } from "../utils/Utils";
|
|
4
|
+
import { match } from "./Match";
|
|
5
|
+
|
|
6
|
+
export const weExpectedButReceivedInstead = ([r, e]: [any, any]) => `We expected ${asString(e)}, but we received '${asString(r)}' instead.`;
|
|
7
|
+
|
|
8
|
+
export function toMatchAsString(this: jest.MatcherContext, received: unknown, expected: unknown): jest.CustomMatcherResult {
|
|
9
|
+
return checkDefined(this, received, expected)
|
|
10
|
+
.not(([r, e]) => this.equals(asString(r), asString(e)), ([r, e]) => weExpectedButReceivedInstead([r, e]))
|
|
11
|
+
.else();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// export function toBeRoutedTo(this: jest.MatcherContext, query: jest.Mock, expected: Uri): jest.CustomMatcherResult {
|
|
15
|
+
// return check<any[]>(this, query?.mock?.calls)
|
|
16
|
+
// .undefined(r => r, "Uri is unknown.")
|
|
17
|
+
// .not(r => r.length === 1, "Method was not called.")
|
|
18
|
+
// .not(r => this.equals(asString(r[0][0]), asString(expected)), ([r,e]) => weExpectedButReceivedInstead([r[0][0], e]))
|
|
19
|
+
// .else();
|
|
20
|
+
// }
|
|
4
21
|
|
|
5
22
|
export const toBeRoutedTo = (query: jest.Mock, expected: Uri): jest.CustomMatcherResult =>
|
|
6
23
|
match<any[]>(query?.mock?.calls)
|
|
@@ -13,7 +30,7 @@ export const toBeRoutedTo = (query: jest.Mock, expected: Uri): jest.CustomMatche
|
|
|
13
30
|
.else(`Called uri does match '${asString(expected)}'`);
|
|
14
31
|
|
|
15
32
|
expect.extend({
|
|
16
|
-
toBeRoutedTo: toBeRoutedTo
|
|
33
|
+
toBeRoutedTo: toBeRoutedTo
|
|
17
34
|
});
|
|
18
35
|
|
|
19
36
|
declare global {
|