@thisisagile/easy-test 15.13.0 → 15.13.1
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 +1 -1
- package/dist/matchers/toBeRoutedTo.js +4 -1
- package/dist/matchers/toBeRoutedTo.js.map +1 -1
- package/dist/matchers/toBeRoutedTo.mjs +4 -1
- package/dist/matchers/toBeRoutedTo.mjs.map +1 -1
- package/dist/matchers/toMatchArray.js +4 -1
- package/dist/matchers/toMatchArray.js.map +1 -1
- package/dist/matchers/toMatchArray.mjs +4 -1
- package/dist/matchers/toMatchArray.mjs.map +1 -1
- package/package.json +1 -1
- package/src/matchers/toBeRoutedTo.ts +9 -6
- package/src/matchers/toMatchArray.ts +8 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
import { Uri } from
|
|
2
|
+
import { Uri } from '../utils/Types';
|
|
3
3
|
export declare const weExpectedButReceivedInstead: ([r, e]: [any, any]) => string;
|
|
4
4
|
export declare function toMatchAsString(this: jest.MatcherContext, received: unknown, expected: unknown): jest.CustomMatcherResult;
|
|
5
5
|
export declare const toBeRoutedTo: (query: jest.Mock, expected: Uri) => jest.CustomMatcherResult;
|
|
@@ -28,7 +28,10 @@ var import_Utils = require("../utils/Utils");
|
|
|
28
28
|
var import_Match = require("./Match");
|
|
29
29
|
const weExpectedButReceivedInstead = ([r, e]) => `We expected ${(0, import_Utils.asString)(e)}, but we received '${(0, import_Utils.asString)(r)}' instead.`;
|
|
30
30
|
function toMatchAsString(received, expected) {
|
|
31
|
-
return (0, import_Check.checkDefined)(this, received, expected).not(
|
|
31
|
+
return (0, import_Check.checkDefined)(this, received, expected).not(
|
|
32
|
+
([r, e]) => this.equals((0, import_Utils.asString)(r), (0, import_Utils.asString)(e)),
|
|
33
|
+
([r, e]) => weExpectedButReceivedInstead([r, e])
|
|
34
|
+
).else();
|
|
32
35
|
}
|
|
33
36
|
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(
|
|
34
37
|
(c) => (0, import_Utils.asString)(c[0][0]) === (0, import_Utils.asString)(expected),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toBeRoutedTo.ts"],"sourcesContent":["import { checkDefined } from
|
|
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(\n ([r, e]) => this.equals(asString(r), asString(e)),\n ([r, e]) => weExpectedButReceivedInstead([r, e])\n )\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;AAAA,IACC,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,WAAO,uBAAS,CAAC,OAAG,uBAAS,CAAC,CAAC;AAAA,IAChD,CAAC,CAAC,GAAG,CAAC,MAAM,6BAA6B,CAAC,GAAG,CAAC,CAAC;AAAA,EACjD,EACC,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":[]}
|
|
@@ -3,7 +3,10 @@ import { asString } from "../utils/Utils";
|
|
|
3
3
|
import { match } from "./Match";
|
|
4
4
|
const weExpectedButReceivedInstead = ([r, e]) => `We expected ${asString(e)}, but we received '${asString(r)}' instead.`;
|
|
5
5
|
function toMatchAsString(received, expected) {
|
|
6
|
-
return checkDefined(this, received, expected).not(
|
|
6
|
+
return checkDefined(this, received, expected).not(
|
|
7
|
+
([r, e]) => this.equals(asString(r), asString(e)),
|
|
8
|
+
([r, e]) => weExpectedButReceivedInstead([r, e])
|
|
9
|
+
).else();
|
|
7
10
|
}
|
|
8
11
|
const toBeRoutedTo = (query, expected) => match(query?.mock?.calls).undefined((c) => c, "Uri is unknown.").not((c) => c.length === 1, "Method was not called.").not(
|
|
9
12
|
(c) => asString(c[0][0]) === asString(expected),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toBeRoutedTo.ts"],"sourcesContent":["import { checkDefined } from
|
|
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(\n ([r, e]) => this.equals(asString(r), asString(e)),\n ([r, e]) => weExpectedButReceivedInstead([r, e])\n )\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;AAAA,IACC,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,OAAO,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;AAAA,IAChD,CAAC,CAAC,GAAG,CAAC,MAAM,6BAA6B,CAAC,GAAG,CAAC,CAAC;AAAA,EACjD,EACC,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":[]}
|
|
@@ -23,7 +23,10 @@ __export(toMatchArray_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(toMatchArray_exports);
|
|
24
24
|
var import_Check = require("./Check");
|
|
25
25
|
function toMatchArray(received, expected) {
|
|
26
|
-
return (0, import_Check.checkDefined)(this, received, expected).not(
|
|
26
|
+
return (0, import_Check.checkDefined)(this, received, expected).not(
|
|
27
|
+
([r, e]) => r.length === e.length,
|
|
28
|
+
([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`
|
|
29
|
+
).not(([r, e]) => r.every((el, i) => this.equals(el, e[i])), "Elements in {r} do not match elements in {e}. \n\n {diff}.").else();
|
|
27
30
|
}
|
|
28
31
|
expect.extend({
|
|
29
32
|
toMatchArray
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toMatchArray.ts"],"sourcesContent":["import { checkDefined } from
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toMatchArray.ts"],"sourcesContent":["import { checkDefined } from './Check';\n\nexport function toMatchArray(this: jest.MatcherContext, received: any[], expected: any[]) {\n return checkDefined(this, received, expected)\n .not(\n ([r, e]) => r.length === e.length,\n ([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`\n )\n .not(([r, e]) => r.every((el, i) => this.equals(el, e[i])), 'Elements in {r} do not match elements in {e}. \\n\\n {diff}.')\n .else();\n}\n\nexpect.extend({\n toMatchArray,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchArray(expected: any[]): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6B;AAEtB,SAAS,aAAwC,UAAiB,UAAiB;AACxF,aAAO,2BAAa,MAAM,UAAU,QAAQ,EACzC;AAAA,IACC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE;AAAA,IAC3B,CAAC,CAAC,GAAG,CAAC,MAAM,6BAA6B,EAAE,MAAM,qCAAqC,EAAE,MAAM;AAAA,EAChG,EACC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,KAAK,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,4DAA4D,EACvH,KAAK;AACV;AAEA,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { checkDefined } from "./Check";
|
|
2
2
|
function toMatchArray(received, expected) {
|
|
3
|
-
return checkDefined(this, received, expected).not(
|
|
3
|
+
return checkDefined(this, received, expected).not(
|
|
4
|
+
([r, e]) => r.length === e.length,
|
|
5
|
+
([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`
|
|
6
|
+
).not(([r, e]) => r.every((el, i) => this.equals(el, e[i])), "Elements in {r} do not match elements in {e}. \n\n {diff}.").else();
|
|
4
7
|
}
|
|
5
8
|
expect.extend({
|
|
6
9
|
toMatchArray
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toMatchArray.ts"],"sourcesContent":["import { checkDefined } from
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toMatchArray.ts"],"sourcesContent":["import { checkDefined } from './Check';\n\nexport function toMatchArray(this: jest.MatcherContext, received: any[], expected: any[]) {\n return checkDefined(this, received, expected)\n .not(\n ([r, e]) => r.length === e.length,\n ([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`\n )\n .not(([r, e]) => r.every((el, i) => this.equals(el, e[i])), 'Elements in {r} do not match elements in {e}. \\n\\n {diff}.')\n .else();\n}\n\nexpect.extend({\n toMatchArray,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchArray(expected: any[]): R;\n }\n }\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAEtB,SAAS,aAAwC,UAAiB,UAAiB;AACxF,SAAO,aAAa,MAAM,UAAU,QAAQ,EACzC;AAAA,IACC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE;AAAA,IAC3B,CAAC,CAAC,GAAG,CAAC,MAAM,6BAA6B,EAAE,MAAM,qCAAqC,EAAE,MAAM;AAAA,EAChG,EACC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,KAAK,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,4DAA4D,EACvH,KAAK;AACV;AAEA,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { checkDefined } from
|
|
2
|
-
import { Uri } from
|
|
3
|
-
import { asString } from
|
|
4
|
-
import { match } from
|
|
1
|
+
import { checkDefined } from './Check';
|
|
2
|
+
import { Uri } from '../utils/Types';
|
|
3
|
+
import { asString } from '../utils/Utils';
|
|
4
|
+
import { match } from './Match';
|
|
5
5
|
|
|
6
6
|
export const weExpectedButReceivedInstead = ([r, e]: [any, any]) => `We expected ${asString(e)}, but we received '${asString(r)}' instead.`;
|
|
7
7
|
|
|
8
8
|
export function toMatchAsString(this: jest.MatcherContext, received: unknown, expected: unknown): jest.CustomMatcherResult {
|
|
9
9
|
return checkDefined(this, received, expected)
|
|
10
|
-
.not(
|
|
10
|
+
.not(
|
|
11
|
+
([r, e]) => this.equals(asString(r), asString(e)),
|
|
12
|
+
([r, e]) => weExpectedButReceivedInstead([r, e])
|
|
13
|
+
)
|
|
11
14
|
.else();
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -30,7 +33,7 @@ export const toBeRoutedTo = (query: jest.Mock, expected: Uri): jest.CustomMatche
|
|
|
30
33
|
.else(`Called uri does match '${asString(expected)}'`);
|
|
31
34
|
|
|
32
35
|
expect.extend({
|
|
33
|
-
toBeRoutedTo: toBeRoutedTo
|
|
36
|
+
toBeRoutedTo: toBeRoutedTo,
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
declare global {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { checkDefined } from
|
|
1
|
+
import { checkDefined } from './Check';
|
|
2
2
|
|
|
3
3
|
export function toMatchArray(this: jest.MatcherContext, received: any[], expected: any[]) {
|
|
4
4
|
return checkDefined(this, received, expected)
|
|
5
|
-
.not(
|
|
6
|
-
|
|
5
|
+
.not(
|
|
6
|
+
([r, e]) => r.length === e.length,
|
|
7
|
+
([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`
|
|
8
|
+
)
|
|
9
|
+
.not(([r, e]) => r.every((el, i) => this.equals(el, e[i])), 'Elements in {r} do not match elements in {e}. \n\n {diff}.')
|
|
7
10
|
.else();
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
expect.extend({
|
|
11
|
-
toMatchArray
|
|
14
|
+
toMatchArray,
|
|
12
15
|
});
|
|
13
16
|
|
|
14
17
|
declare global {
|
|
@@ -18,4 +21,4 @@ declare global {
|
|
|
18
21
|
toMatchArray(expected: any[]): R;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
}
|
|
24
|
+
}
|