@thisisagile/easy-test 15.26.2 → 15.27.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.
- package/dist/chunk-6EKWTLNQ.mjs +12 -0
- package/dist/chunk-6EKWTLNQ.mjs.map +1 -0
- package/dist/chunk-KAVJOG5T.mjs +39 -0
- package/dist/chunk-KAVJOG5T.mjs.map +1 -0
- package/dist/chunk-LN24S2PC.mjs +41 -0
- package/dist/chunk-LN24S2PC.mjs.map +1 -0
- package/dist/chunk-O475TEG2.mjs +30 -0
- package/dist/chunk-O475TEG2.mjs.map +1 -0
- package/dist/chunk-QE3TR4BY.mjs +16 -0
- package/dist/chunk-QE3TR4BY.mjs.map +1 -0
- package/dist/chunk-Z4XAP66Q.mjs +44 -0
- package/dist/chunk-Z4XAP66Q.mjs.map +1 -0
- package/dist/index.js +590 -5
- package/dist/index.js.map +1 -1
- package/dist/matchers/Check.mjs +5 -34
- package/dist/matchers/Check.mjs.map +1 -1
- package/dist/matchers/HttpMatchers.mjs +19 -13
- package/dist/matchers/HttpMatchers.mjs.map +1 -1
- package/dist/matchers/Match.mjs +6 -29
- package/dist/matchers/Match.mjs.map +1 -1
- package/dist/matchers/ResultMatchers.mjs +14 -8
- package/dist/matchers/ResultMatchers.mjs.map +1 -1
- package/dist/matchers/toBeArrayOf.mjs +8 -2
- package/dist/matchers/toBeArrayOf.mjs.map +1 -1
- package/dist/matchers/toBeArrayOfWithLength.mjs +8 -2
- package/dist/matchers/toBeArrayOfWithLength.mjs.map +1 -1
- package/dist/matchers/toBeAt.mjs +8 -2
- package/dist/matchers/toBeAt.mjs.map +1 -1
- package/dist/matchers/toBeExactlyAt.mjs +11 -4
- package/dist/matchers/toBeExactlyAt.mjs.map +1 -1
- package/dist/matchers/toBeQueriedWith.mjs +8 -2
- package/dist/matchers/toBeQueriedWith.mjs.map +1 -1
- package/dist/matchers/toBeRoutedTo.mjs +14 -5
- package/dist/matchers/toBeRoutedTo.mjs.map +1 -1
- package/dist/matchers/toBeValid.mjs +10 -3
- package/dist/matchers/toBeValid.mjs.map +1 -1
- package/dist/matchers/toFailMatcher.mjs +13 -6
- package/dist/matchers/toFailMatcher.mjs.map +1 -1
- package/dist/matchers/toMatchArray.mjs +6 -1
- package/dist/matchers/toMatchArray.mjs.map +1 -1
- package/dist/matchers/toMatchExactJson.mjs +12 -4
- package/dist/matchers/toMatchExactJson.mjs.map +1 -1
- package/dist/matchers/toMatchException.mjs +10 -3
- package/dist/matchers/toMatchException.mjs.map +1 -1
- package/dist/matchers/toMatchJson.mjs +14 -5
- package/dist/matchers/toMatchJson.mjs.map +1 -1
- package/dist/matchers/toMatchRoute.mjs +10 -3
- package/dist/matchers/toMatchRoute.mjs.map +1 -1
- package/dist/matchers/toMatchText.mjs +10 -3
- package/dist/matchers/toMatchText.mjs.map +1 -1
- package/dist/matchers/toPassMatcher.mjs +13 -6
- package/dist/matchers/toPassMatcher.mjs.map +1 -1
- package/dist/mock/Fits.mjs +17 -9
- package/dist/mock/Fits.mjs.map +1 -1
- package/dist/mock/Mocks.mjs +9 -4
- package/dist/mock/Mocks.mjs.map +1 -1
- package/dist/utils/Eq.mjs +4 -7
- package/dist/utils/Eq.mjs.map +1 -1
- package/dist/utils/Req.mjs +4 -29
- package/dist/utils/Req.mjs.map +1 -1
- package/dist/utils/Types.mjs +4 -2
- package/dist/utils/Types.mjs.map +1 -1
- package/dist/utils/Utils.mjs +13 -14
- package/dist/utils/Utils.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/matchers/Check.js +0 -64
- package/dist/matchers/Check.js.map +0 -1
- package/dist/matchers/HttpMatchers.js +0 -89
- package/dist/matchers/HttpMatchers.js.map +0 -1
- package/dist/matchers/Match.js +0 -59
- package/dist/matchers/Match.js.map +0 -1
- package/dist/matchers/ResultMatchers.js +0 -51
- package/dist/matchers/ResultMatchers.js.map +0 -1
- package/dist/matchers/index.js +0 -59
- package/dist/matchers/index.js.map +0 -1
- package/dist/matchers/toBeArrayOf.js +0 -33
- package/dist/matchers/toBeArrayOf.js.map +0 -1
- package/dist/matchers/toBeArrayOfWithLength.js +0 -36
- package/dist/matchers/toBeArrayOfWithLength.js.map +0 -1
- package/dist/matchers/toBeAt.js +0 -44
- package/dist/matchers/toBeAt.js.map +0 -1
- package/dist/matchers/toBeExactlyAt.js +0 -43
- package/dist/matchers/toBeExactlyAt.js.map +0 -1
- package/dist/matchers/toBeQueriedWith.js +0 -36
- package/dist/matchers/toBeQueriedWith.js.map +0 -1
- package/dist/matchers/toBeRoutedTo.js +0 -49
- package/dist/matchers/toBeRoutedTo.js.map +0 -1
- package/dist/matchers/toBeValid.js +0 -34
- package/dist/matchers/toBeValid.js.map +0 -1
- package/dist/matchers/toFailMatcher.js +0 -59
- package/dist/matchers/toFailMatcher.js.map +0 -1
- package/dist/matchers/toMatchArray.js +0 -38
- package/dist/matchers/toMatchArray.js.map +0 -1
- package/dist/matchers/toMatchExactJson.js +0 -42
- package/dist/matchers/toMatchExactJson.js.map +0 -1
- package/dist/matchers/toMatchException.js +0 -43
- package/dist/matchers/toMatchException.js.map +0 -1
- package/dist/matchers/toMatchJson.js +0 -43
- package/dist/matchers/toMatchJson.js.map +0 -1
- package/dist/matchers/toMatchRoute.js +0 -37
- package/dist/matchers/toMatchRoute.js.map +0 -1
- package/dist/matchers/toMatchText.js +0 -37
- package/dist/matchers/toMatchText.js.map +0 -1
- package/dist/matchers/toPassMatcher.js +0 -59
- package/dist/matchers/toPassMatcher.js.map +0 -1
- package/dist/mock/Fits.js +0 -71
- package/dist/mock/Fits.js.map +0 -1
- package/dist/mock/Mocks.js +0 -98
- package/dist/mock/Mocks.js.map +0 -1
- package/dist/mock/index.js +0 -25
- package/dist/mock/index.js.map +0 -1
- package/dist/utils/Eq.js +0 -35
- package/dist/utils/Eq.js.map +0 -1
- package/dist/utils/Req.js +0 -57
- package/dist/utils/Req.js.map +0 -1
- package/dist/utils/Response.js +0 -17
- package/dist/utils/Response.js.map +0 -1
- package/dist/utils/Types.js +0 -30
- package/dist/utils/Types.js.map +0 -1
- package/dist/utils/Utils.js +0 -62
- package/dist/utils/Utils.js.map +0 -1
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
checkDefined
|
|
3
|
+
} from "../chunk-Z4XAP66Q.mjs";
|
|
4
|
+
import "../chunk-O475TEG2.mjs";
|
|
5
|
+
|
|
6
|
+
// src/matchers/toMatchArray.ts
|
|
2
7
|
function toMatchArray(received, expected) {
|
|
3
8
|
return checkDefined(this, received, expected).not(
|
|
4
9
|
([r, e]) => r.length === e.length,
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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":";;;;;;AAEO,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":[]}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
eq
|
|
3
|
+
} from "../chunk-QE3TR4BY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
match
|
|
6
|
+
} from "../chunk-LN24S2PC.mjs";
|
|
7
|
+
import "../chunk-6EKWTLNQ.mjs";
|
|
8
|
+
import "../chunk-O475TEG2.mjs";
|
|
9
|
+
|
|
10
|
+
// src/matchers/toMatchExactJson.ts
|
|
11
|
+
var MatchesExactJson = {
|
|
4
12
|
SubjectUndefined: "Subject is undefined.",
|
|
5
13
|
SubsetUndefined: "Object to match with is undefined.",
|
|
6
14
|
DoesNotMatch: "Object does not exactly match subject.",
|
|
7
15
|
Yes: "Object matches subject exactly"
|
|
8
16
|
};
|
|
9
|
-
|
|
17
|
+
var toMatchExactJson = (value, json) => match(value).undefined((v) => v, MatchesExactJson.SubjectUndefined).undefined(() => json, MatchesExactJson.SubsetUndefined).not((v) => eq.exact(v, json), MatchesExactJson.DoesNotMatch).else(() => MatchesExactJson.Yes);
|
|
10
18
|
expect.extend({
|
|
11
19
|
toMatchExactJson
|
|
12
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toMatchExactJson.ts"],"sourcesContent":["import { match } from './Match';\nimport { eq } from '../utils/Eq';\n\nexport const MatchesExactJson = {\n SubjectUndefined: 'Subject is undefined.',\n SubsetUndefined: 'Object to match with is undefined.',\n DoesNotMatch: 'Object does not exactly match subject.',\n Yes: 'Object matches subject exactly',\n};\n\nexport const toMatchExactJson = (value?: unknown, json?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, MatchesExactJson.SubjectUndefined)\n .undefined(() => json, MatchesExactJson.SubsetUndefined)\n .not(v => eq.exact(v, json), MatchesExactJson.DoesNotMatch)\n .else(() => MatchesExactJson.Yes);\n\nexpect.extend({\n toMatchExactJson: toMatchExactJson,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchExactJson(json?: unknown): R;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toMatchExactJson.ts"],"sourcesContent":["import { match } from './Match';\nimport { eq } from '../utils/Eq';\n\nexport const MatchesExactJson = {\n SubjectUndefined: 'Subject is undefined.',\n SubsetUndefined: 'Object to match with is undefined.',\n DoesNotMatch: 'Object does not exactly match subject.',\n Yes: 'Object matches subject exactly',\n};\n\nexport const toMatchExactJson = (value?: unknown, json?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, MatchesExactJson.SubjectUndefined)\n .undefined(() => json, MatchesExactJson.SubsetUndefined)\n .not(v => eq.exact(v, json), MatchesExactJson.DoesNotMatch)\n .else(() => MatchesExactJson.Yes);\n\nexpect.extend({\n toMatchExactJson: toMatchExactJson,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchExactJson(json?: unknown): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAGO,IAAM,mBAAmB;AAAA,EAC9B,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,KAAK;AACP;AAEO,IAAM,mBAAmB,CAAC,OAAiB,SAChD,MAAe,KAAK,EACjB,UAAU,OAAK,GAAG,iBAAiB,gBAAgB,EACnD,UAAU,MAAM,MAAM,iBAAiB,eAAe,EACtD,IAAI,OAAK,GAAG,MAAM,GAAG,IAAI,GAAG,iBAAiB,YAAY,EACzD,KAAK,MAAM,iBAAiB,GAAG;AAEpC,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
match
|
|
3
|
+
} from "../chunk-LN24S2PC.mjs";
|
|
4
|
+
import "../chunk-6EKWTLNQ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
isDefined
|
|
7
|
+
} from "../chunk-O475TEG2.mjs";
|
|
8
|
+
|
|
9
|
+
// src/matchers/toMatchException.ts
|
|
10
|
+
var toMatchException = (received, expected, reason) => match(expected).undefined((e) => e.id, "Expected value is not an exception.").not(
|
|
4
11
|
(e) => e.id === received.id,
|
|
5
12
|
(e) => `Expected exception has id '${e.id}', while the received exception has id '${received.id}'.`
|
|
6
13
|
).not(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toMatchException.ts"],"sourcesContent":["import { Exception } from '../utils/Types';\nimport { match } from './Match';\nimport { isDefined } from '../utils/Utils';\n\nexport const toMatchException = (received: Exception, expected: unknown, reason?: string): jest.CustomMatcherResult =>\n match<Exception>(expected as Exception)\n .undefined(e => e.id, 'Expected value is not an exception.')\n .not(\n e => e.id === received.id,\n e => `Expected exception has id '${e.id}', while the received exception has id '${received.id}'.`\n )\n .not(\n () => !isDefined(reason) || (isDefined(reason) && isDefined(received.reason)),\n () => `We expected to have reason '${reason}', but we received no reason.`\n )\n .not(\n () => !isDefined(reason) || (isDefined(reason) && received.reason === reason),\n () => `We expected to have reason '${reason}', but we received reason '${received.reason}'.`\n )\n .else(`Expected exception matches received exception`);\n\nexpect.extend({\n toMatchException,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchException(exception: unknown, reason?: string): R;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toMatchException.ts"],"sourcesContent":["import { Exception } from '../utils/Types';\nimport { match } from './Match';\nimport { isDefined } from '../utils/Utils';\n\nexport const toMatchException = (received: Exception, expected: unknown, reason?: string): jest.CustomMatcherResult =>\n match<Exception>(expected as Exception)\n .undefined(e => e.id, 'Expected value is not an exception.')\n .not(\n e => e.id === received.id,\n e => `Expected exception has id '${e.id}', while the received exception has id '${received.id}'.`\n )\n .not(\n () => !isDefined(reason) || (isDefined(reason) && isDefined(received.reason)),\n () => `We expected to have reason '${reason}', but we received no reason.`\n )\n .not(\n () => !isDefined(reason) || (isDefined(reason) && received.reason === reason),\n () => `We expected to have reason '${reason}', but we received reason '${received.reason}'.`\n )\n .else(`Expected exception matches received exception`);\n\nexpect.extend({\n toMatchException,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchException(exception: unknown, reason?: string): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;AAIO,IAAM,mBAAmB,CAAC,UAAqB,UAAmB,WACvE,MAAiB,QAAqB,EACnC,UAAU,OAAK,EAAE,IAAI,qCAAqC,EAC1D;AAAA,EACC,OAAK,EAAE,OAAO,SAAS;AAAA,EACvB,OAAK,8BAA8B,EAAE,EAAE,2CAA2C,SAAS,EAAE;AAC/F,EACC;AAAA,EACC,MAAM,CAAC,UAAU,MAAM,KAAM,UAAU,MAAM,KAAK,UAAU,SAAS,MAAM;AAAA,EAC3E,MAAM,+BAA+B,MAAM;AAC7C,EACC;AAAA,EACC,MAAM,CAAC,UAAU,MAAM,KAAM,UAAU,MAAM,KAAK,SAAS,WAAW;AAAA,EACtE,MAAM,+BAA+B,MAAM,8BAA8B,SAAS,MAAM;AAC1F,EACC,KAAK,+CAA+C;AAEzD,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
eq
|
|
3
|
+
} from "../chunk-QE3TR4BY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
match
|
|
6
|
+
} from "../chunk-LN24S2PC.mjs";
|
|
7
|
+
import "../chunk-6EKWTLNQ.mjs";
|
|
8
|
+
import {
|
|
9
|
+
asJson
|
|
10
|
+
} from "../chunk-O475TEG2.mjs";
|
|
11
|
+
|
|
12
|
+
// src/matchers/toMatchJson.ts
|
|
13
|
+
var MatchesJson = {
|
|
5
14
|
SubjectUndefined: "Subject is undefined.",
|
|
6
15
|
SubsetUndefined: "Subset to match with is undefined.",
|
|
7
16
|
DoesNotMatch: "Subset does not match subject.",
|
|
8
17
|
Yes: "Subset matches subject"
|
|
9
18
|
};
|
|
10
|
-
|
|
19
|
+
var toMatchJson = (value, subset) => match(value).undefined((v) => v, MatchesJson.SubjectUndefined).undefined(() => subset, MatchesJson.SubsetUndefined).not((v) => eq.subset(asJson(v), asJson(subset)), MatchesJson.DoesNotMatch).else(() => MatchesJson.Yes);
|
|
11
20
|
expect.extend({
|
|
12
21
|
toMatchJson
|
|
13
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toMatchJson.ts"],"sourcesContent":["import { match } from './Match';\nimport { eq } from '../utils/Eq';\nimport { asJson } from '../utils/Utils';\n\nexport const MatchesJson = {\n SubjectUndefined: 'Subject is undefined.',\n SubsetUndefined: 'Subset to match with is undefined.',\n DoesNotMatch: 'Subset does not match subject.',\n Yes: 'Subset matches subject',\n};\n\nexport const toMatchJson = (value?: unknown, subset?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, MatchesJson.SubjectUndefined)\n .undefined(() => subset, MatchesJson.SubsetUndefined)\n .not(v => eq.subset(asJson(v), asJson(subset)), MatchesJson.DoesNotMatch)\n .else(() => MatchesJson.Yes);\n\nexpect.extend({\n toMatchJson: toMatchJson,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchJson(subset?: unknown): R;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toMatchJson.ts"],"sourcesContent":["import { match } from './Match';\nimport { eq } from '../utils/Eq';\nimport { asJson } from '../utils/Utils';\n\nexport const MatchesJson = {\n SubjectUndefined: 'Subject is undefined.',\n SubsetUndefined: 'Subset to match with is undefined.',\n DoesNotMatch: 'Subset does not match subject.',\n Yes: 'Subset matches subject',\n};\n\nexport const toMatchJson = (value?: unknown, subset?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, MatchesJson.SubjectUndefined)\n .undefined(() => subset, MatchesJson.SubsetUndefined)\n .not(v => eq.subset(asJson(v), asJson(subset)), MatchesJson.DoesNotMatch)\n .else(() => MatchesJson.Yes);\n\nexpect.extend({\n toMatchJson: toMatchJson,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchJson(subset?: unknown): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AAIO,IAAM,cAAc;AAAA,EACzB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,KAAK;AACP;AAEO,IAAM,cAAc,CAAC,OAAiB,WAC3C,MAAe,KAAK,EACjB,UAAU,OAAK,GAAG,YAAY,gBAAgB,EAC9C,UAAU,MAAM,QAAQ,YAAY,eAAe,EACnD,IAAI,OAAK,GAAG,OAAO,OAAO,CAAC,GAAG,OAAO,MAAM,CAAC,GAAG,YAAY,YAAY,EACvE,KAAK,MAAM,YAAY,GAAG;AAE/B,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
match
|
|
3
|
+
} from "../chunk-LN24S2PC.mjs";
|
|
4
|
+
import "../chunk-6EKWTLNQ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
asString
|
|
7
|
+
} from "../chunk-O475TEG2.mjs";
|
|
8
|
+
|
|
9
|
+
// src/matchers/toMatchRoute.ts
|
|
10
|
+
var toMatchRoute = (uri, route) => match(uri).undefined((u) => u, "Subject is undefined.").undefined(() => route, "Route to include is undefined.").not(
|
|
4
11
|
(u) => asString(u).includes(asString(route)),
|
|
5
12
|
(u) => `Uri '${u}' does not include '${route}'.`
|
|
6
13
|
).else((u) => `Uri '${u}' includes '${route}'`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toMatchRoute.ts"],"sourcesContent":["import { Uri } from '../utils/Types';\nimport { match } from './Match';\nimport { asString } from '../utils/Utils';\n\nexport const toMatchRoute = (uri?: Uri, route?: Uri | string): jest.CustomMatcherResult =>\n match<Uri | undefined>(uri)\n .undefined(u => u, 'Subject is undefined.')\n .undefined(() => route, 'Route to include is undefined.')\n .not(\n u => asString(u).includes(asString(route)),\n u => `Uri '${u}' does not include '${route}'.`\n )\n .else(u => `Uri '${u}' includes '${route}'`);\n\nexpect.extend({\n toMatchRoute: toMatchRoute,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchRoute(route?: Uri | string): R;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toMatchRoute.ts"],"sourcesContent":["import { Uri } from '../utils/Types';\nimport { match } from './Match';\nimport { asString } from '../utils/Utils';\n\nexport const toMatchRoute = (uri?: Uri, route?: Uri | string): jest.CustomMatcherResult =>\n match<Uri | undefined>(uri)\n .undefined(u => u, 'Subject is undefined.')\n .undefined(() => route, 'Route to include is undefined.')\n .not(\n u => asString(u).includes(asString(route)),\n u => `Uri '${u}' does not include '${route}'.`\n )\n .else(u => `Uri '${u}' includes '${route}'`);\n\nexpect.extend({\n toMatchRoute: toMatchRoute,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchRoute(route?: Uri | string): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;AAIO,IAAM,eAAe,CAAC,KAAW,UACtC,MAAuB,GAAG,EACvB,UAAU,OAAK,GAAG,uBAAuB,EACzC,UAAU,MAAM,OAAO,gCAAgC,EACvD;AAAA,EACC,OAAK,SAAS,CAAC,EAAE,SAAS,SAAS,KAAK,CAAC;AAAA,EACzC,OAAK,QAAQ,CAAC,uBAAuB,KAAK;AAC5C,EACC,KAAK,OAAK,QAAQ,CAAC,eAAe,KAAK,GAAG;AAE/C,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
match
|
|
3
|
+
} from "../chunk-LN24S2PC.mjs";
|
|
4
|
+
import "../chunk-6EKWTLNQ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
asString
|
|
7
|
+
} from "../chunk-O475TEG2.mjs";
|
|
8
|
+
|
|
9
|
+
// src/matchers/toMatchText.ts
|
|
10
|
+
var toMatchText = (value, text) => match(value).undefined((v) => v, "Subject is undefined.").undefined(() => text, "Text to match with is undefined.").not(
|
|
4
11
|
(v) => asString(v) === asString(text),
|
|
5
12
|
(v) => `Text '${v}' does not match with text '${text}'.`
|
|
6
13
|
).else((v) => `Text '${v}' matches`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toMatchText.ts"],"sourcesContent":["import { match } from './Match';\nimport { asString } from '../utils/Utils';\n\nexport const toMatchText = (value?: unknown, text?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, 'Subject is undefined.')\n .undefined(() => text, 'Text to match with is undefined.')\n .not(\n v => asString(v) === asString(text),\n v => `Text '${v}' does not match with text '${text}'.`\n )\n .else(v => `Text '${v}' matches`);\n\nexpect.extend({\n toMatchText: toMatchText,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchText(text?: unknown): R;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toMatchText.ts"],"sourcesContent":["import { match } from './Match';\nimport { asString } from '../utils/Utils';\n\nexport const toMatchText = (value?: unknown, text?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, 'Subject is undefined.')\n .undefined(() => text, 'Text to match with is undefined.')\n .not(\n v => asString(v) === asString(text),\n v => `Text '${v}' does not match with text '${text}'.`\n )\n .else(v => `Text '${v}' matches`);\n\nexpect.extend({\n toMatchText: toMatchText,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchText(text?: unknown): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;AAGO,IAAM,cAAc,CAAC,OAAiB,SAC3C,MAAe,KAAK,EACjB,UAAU,OAAK,GAAG,uBAAuB,EACzC,UAAU,MAAM,MAAM,kCAAkC,EACxD;AAAA,EACC,OAAK,SAAS,CAAC,MAAM,SAAS,IAAI;AAAA,EAClC,OAAK,SAAS,CAAC,+BAA+B,IAAI;AACpD,EACC,KAAK,OAAK,SAAS,CAAC,WAAW;AAEpC,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
match
|
|
3
|
+
} from "../chunk-LN24S2PC.mjs";
|
|
4
|
+
import {
|
|
5
|
+
toMessage
|
|
6
|
+
} from "../chunk-6EKWTLNQ.mjs";
|
|
7
|
+
import "../chunk-O475TEG2.mjs";
|
|
8
|
+
|
|
9
|
+
// src/matchers/toPassMatcher.ts
|
|
10
|
+
var Passes = {
|
|
4
11
|
Yes: "Match passes, instead of fails.",
|
|
5
12
|
No: (reason) => `Match doesn't pass, because '${reason}'`
|
|
6
13
|
};
|
|
7
|
-
|
|
14
|
+
var PassesWith = {
|
|
8
15
|
Yes: "Match passes with correct message.",
|
|
9
16
|
No: (message, instead) => `Match does pass, however not with message '${message}', but with message '${instead}' instead.`
|
|
10
17
|
};
|
|
11
|
-
|
|
18
|
+
var toPassMatcher = (result) => match(result).not(
|
|
12
19
|
(c) => c.pass,
|
|
13
20
|
(c) => Passes.No(c.message())
|
|
14
21
|
).else(Passes.Yes);
|
|
15
|
-
|
|
22
|
+
var toPassMatcherWith = (result, message) => match(result).not(
|
|
16
23
|
(c) => c.pass,
|
|
17
24
|
(c) => Passes.No(c.message())
|
|
18
25
|
).not(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/toPassMatcher.ts"],"sourcesContent":["import { match } from './Match';\n\nimport { Message, toMessage } from '../utils/Types';\n\n// Handles CustomMatcherResult validations.\n\nexport const Passes = {\n Yes: 'Match passes, instead of fails.',\n No: (reason: string): string => `Match doesn't pass, because '${reason}'`,\n};\n\nexport const PassesWith = {\n Yes: 'Match passes with correct message.',\n No: (message: string, instead: string): string => `Match does pass, however not with message '${message}', but with message '${instead}' instead.`,\n};\n\nexport const toPassMatcher = (result: jest.CustomMatcherResult): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => c.pass,\n c => Passes.No(c.message())\n )\n .else(Passes.Yes);\n\nexport const toPassMatcherWith = (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => c.pass,\n c => Passes.No(c.message())\n )\n .not(\n c => c.message().includes(toMessage(message)),\n c => PassesWith.No(toMessage(message), c.message())\n )\n .else(PassesWith.Yes);\n\nexpect.extend({\n toPassMatcher: toPassMatcher,\n toPassMatcherWith: toPassMatcherWith,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toPassMatcher(): R;\n toPassMatcherWith(message: string): R;\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/matchers/toPassMatcher.ts"],"sourcesContent":["import { match } from './Match';\n\nimport { Message, toMessage } from '../utils/Types';\n\n// Handles CustomMatcherResult validations.\n\nexport const Passes = {\n Yes: 'Match passes, instead of fails.',\n No: (reason: string): string => `Match doesn't pass, because '${reason}'`,\n};\n\nexport const PassesWith = {\n Yes: 'Match passes with correct message.',\n No: (message: string, instead: string): string => `Match does pass, however not with message '${message}', but with message '${instead}' instead.`,\n};\n\nexport const toPassMatcher = (result: jest.CustomMatcherResult): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => c.pass,\n c => Passes.No(c.message())\n )\n .else(Passes.Yes);\n\nexport const toPassMatcherWith = (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => c.pass,\n c => Passes.No(c.message())\n )\n .not(\n c => c.message().includes(toMessage(message)),\n c => PassesWith.No(toMessage(message), c.message())\n )\n .else(PassesWith.Yes);\n\nexpect.extend({\n toPassMatcher: toPassMatcher,\n toPassMatcherWith: toPassMatcherWith,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toPassMatcher(): R;\n toPassMatcherWith(message: string): R;\n }\n }\n}\n"],"mappings":";;;;;;;;;AAMO,IAAM,SAAS;AAAA,EACpB,KAAK;AAAA,EACL,IAAI,CAAC,WAA2B,gCAAgC,MAAM;AACxE;AAEO,IAAM,aAAa;AAAA,EACxB,KAAK;AAAA,EACL,IAAI,CAAC,SAAiB,YAA4B,8CAA8C,OAAO,wBAAwB,OAAO;AACxI;AAEO,IAAM,gBAAgB,CAAC,WAC5B,MAAM,MAAM,EACT;AAAA,EACC,OAAK,EAAE;AAAA,EACP,OAAK,OAAO,GAAG,EAAE,QAAQ,CAAC;AAC5B,EACC,KAAK,OAAO,GAAG;AAEb,IAAM,oBAAoB,CAAC,QAAkC,YAClE,MAAM,MAAM,EACT;AAAA,EACC,OAAK,EAAE;AAAA,EACP,OAAK,OAAO,GAAG,EAAE,QAAQ,CAAC;AAC5B,EACC;AAAA,EACC,OAAK,EAAE,QAAQ,EAAE,SAAS,UAAU,OAAO,CAAC;AAAA,EAC5C,OAAK,WAAW,GAAG,UAAU,OAAO,GAAG,EAAE,QAAQ,CAAC;AACpD,EACC,KAAK,WAAW,GAAG;AAExB,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AACF,CAAC;","names":[]}
|
package/dist/mock/Fits.mjs
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
eq
|
|
3
|
+
} from "../chunk-QE3TR4BY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
asJson,
|
|
6
|
+
asString,
|
|
7
|
+
toArray
|
|
8
|
+
} from "../chunk-O475TEG2.mjs";
|
|
9
|
+
|
|
10
|
+
// src/mock/Fits.ts
|
|
3
11
|
import { AsymmetricMatcher } from "expect";
|
|
4
|
-
|
|
12
|
+
var ObjectContainingText = class extends AsymmetricMatcher {
|
|
5
13
|
asymmetricMatch(other) {
|
|
6
14
|
return asString(other).includes(asString(this.sample));
|
|
7
15
|
}
|
|
8
16
|
toString() {
|
|
9
17
|
return `String${this.inverse ? "Not" : ""}Containing`;
|
|
10
18
|
}
|
|
11
|
-
}
|
|
12
|
-
|
|
19
|
+
};
|
|
20
|
+
var ObjectContainingTextExact = class extends AsymmetricMatcher {
|
|
13
21
|
asymmetricMatch(other) {
|
|
14
22
|
return asString(other) === asString(this.sample);
|
|
15
23
|
}
|
|
16
24
|
toString() {
|
|
17
25
|
return `String${this.inverse ? "Not" : ""}Containing`;
|
|
18
26
|
}
|
|
19
|
-
}
|
|
20
|
-
|
|
27
|
+
};
|
|
28
|
+
var ObjectContainingJson = class extends AsymmetricMatcher {
|
|
21
29
|
asymmetricMatch(other) {
|
|
22
30
|
return eq.subset(asJson(other), asJson(this.sample));
|
|
23
31
|
}
|
|
24
32
|
toString() {
|
|
25
33
|
return `Object${this.inverse ? "Not" : ""}Containing`;
|
|
26
34
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
35
|
+
};
|
|
36
|
+
var fits = {
|
|
29
37
|
any: () => expect.anything(),
|
|
30
38
|
type: (type) => expect.any(type),
|
|
31
39
|
with: (o) => expect.objectContaining(o),
|
package/dist/mock/Fits.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mock/Fits.ts"],"sourcesContent":["import { asJson, asString, toArray } from '../utils/Utils';\nimport { eq } from '../utils/Eq';\nimport { AsymmetricMatcher } from 'expect';\nimport { Uri } from '../utils/Types';\n\nexport class ObjectContainingText extends AsymmetricMatcher<string> {\n asymmetricMatch(other: any) {\n return asString(other).includes(asString(this.sample));\n }\n\n toString() {\n return `String${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport class ObjectContainingTextExact extends AsymmetricMatcher<string> {\n asymmetricMatch(other: any) {\n return asString(other) === asString(this.sample);\n }\n\n toString() {\n return `String${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport class ObjectContainingJson extends AsymmetricMatcher<any> {\n asymmetricMatch(other: any) {\n return eq.subset(asJson(other), asJson(this.sample));\n }\n\n toString() {\n return `Object${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport const fits = {\n any: (): any => expect.anything(),\n type: (type?: unknown): any => expect.any(type),\n with: (o: unknown): any => expect.objectContaining(o),\n text: (s: any): any => new ObjectContainingText(s),\n textExact: (s: any): any => new ObjectContainingTextExact(s),\n uri: (u: Uri): any => fits.textExact(u),\n json: (s: any): any => new ObjectContainingJson(s),\n items: (...items: any[]): any => expect.arrayContaining(toArray(...items)),\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/mock/Fits.ts"],"sourcesContent":["import { asJson, asString, toArray } from '../utils/Utils';\nimport { eq } from '../utils/Eq';\nimport { AsymmetricMatcher } from 'expect';\nimport { Uri } from '../utils/Types';\n\nexport class ObjectContainingText extends AsymmetricMatcher<string> {\n asymmetricMatch(other: any) {\n return asString(other).includes(asString(this.sample));\n }\n\n toString() {\n return `String${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport class ObjectContainingTextExact extends AsymmetricMatcher<string> {\n asymmetricMatch(other: any) {\n return asString(other) === asString(this.sample);\n }\n\n toString() {\n return `String${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport class ObjectContainingJson extends AsymmetricMatcher<any> {\n asymmetricMatch(other: any) {\n return eq.subset(asJson(other), asJson(this.sample));\n }\n\n toString() {\n return `Object${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport const fits = {\n any: (): any => expect.anything(),\n type: (type?: unknown): any => expect.any(type),\n with: (o: unknown): any => expect.objectContaining(o),\n text: (s: any): any => new ObjectContainingText(s),\n textExact: (s: any): any => new ObjectContainingTextExact(s),\n uri: (u: Uri): any => fits.textExact(u),\n json: (s: any): any => new ObjectContainingJson(s),\n items: (...items: any[]): any => expect.arrayContaining(toArray(...items)),\n};\n"],"mappings":";;;;;;;;;;AAEA,SAAS,yBAAyB;AAG3B,IAAM,uBAAN,cAAmC,kBAA0B;AAAA,EAClE,gBAAgB,OAAY;AAC1B,WAAO,SAAS,KAAK,EAAE,SAAS,SAAS,KAAK,MAAM,CAAC;AAAA,EACvD;AAAA,EAEA,WAAW;AACT,WAAO,SAAS,KAAK,UAAU,QAAQ,EAAE;AAAA,EAC3C;AACF;AAEO,IAAM,4BAAN,cAAwC,kBAA0B;AAAA,EACvE,gBAAgB,OAAY;AAC1B,WAAO,SAAS,KAAK,MAAM,SAAS,KAAK,MAAM;AAAA,EACjD;AAAA,EAEA,WAAW;AACT,WAAO,SAAS,KAAK,UAAU,QAAQ,EAAE;AAAA,EAC3C;AACF;AAEO,IAAM,uBAAN,cAAmC,kBAAuB;AAAA,EAC/D,gBAAgB,OAAY;AAC1B,WAAO,GAAG,OAAO,OAAO,KAAK,GAAG,OAAO,KAAK,MAAM,CAAC;AAAA,EACrD;AAAA,EAEA,WAAW;AACT,WAAO,SAAS,KAAK,UAAU,QAAQ,EAAE;AAAA,EAC3C;AACF;AAEO,IAAM,OAAO;AAAA,EAClB,KAAK,MAAW,OAAO,SAAS;AAAA,EAChC,MAAM,CAAC,SAAwB,OAAO,IAAI,IAAI;AAAA,EAC9C,MAAM,CAAC,MAAoB,OAAO,iBAAiB,CAAC;AAAA,EACpD,MAAM,CAAC,MAAgB,IAAI,qBAAqB,CAAC;AAAA,EACjD,WAAW,CAAC,MAAgB,IAAI,0BAA0B,CAAC;AAAA,EAC3D,KAAK,CAAC,MAAgB,KAAK,UAAU,CAAC;AAAA,EACtC,MAAM,CAAC,MAAgB,IAAI,qBAAqB,CAAC;AAAA,EACjD,OAAO,IAAI,UAAsB,OAAO,gBAAgB,QAAQ,GAAG,KAAK,CAAC;AAC3E;","names":[]}
|
package/dist/mock/Mocks.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Req
|
|
3
|
+
} from "../chunk-KAVJOG5T.mjs";
|
|
4
|
+
import "../chunk-O475TEG2.mjs";
|
|
5
|
+
|
|
6
|
+
// src/mock/Mocks.ts
|
|
7
|
+
var Mocks = class {
|
|
3
8
|
clear = () => jest.clearAllMocks();
|
|
4
9
|
impl = (f) => jest.fn().mockImplementation(f);
|
|
5
10
|
property = (object, getter, value) => jest.spyOn(object, getter, "get").mockReturnValue(value);
|
|
@@ -64,8 +69,8 @@ class Mocks {
|
|
|
64
69
|
return date;
|
|
65
70
|
};
|
|
66
71
|
once = (...values) => values.reduce((m, v) => m.mockImplementationOnce(() => v), jest.fn());
|
|
67
|
-
}
|
|
68
|
-
|
|
72
|
+
};
|
|
73
|
+
var mock = new Mocks();
|
|
69
74
|
export {
|
|
70
75
|
Mocks,
|
|
71
76
|
mock
|
package/dist/mock/Mocks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mock/Mocks.ts"],"sourcesContent":["import { Id, Json } from '../utils/Types';\nimport { Req } from '../utils/Req';\nimport { HttpStatus, Response } from '../utils/Response';\n\nexport class Mocks {\n clear = (): typeof jest => jest.clearAllMocks();\n impl = (f?: (...args: any[]) => any): jest.Mock => jest.fn().mockImplementation(f);\n property = <T extends object, P extends jest.NonFunctionPropertyNames<Required<T>>>(object: T, getter: P, value: T[P]): jest.SpyInstance =>\n jest.spyOn(object, getter, 'get' as jest.PropertyAccessors<P, T>).mockReturnValue(value as any);\n reject = (value?: unknown): jest.Mock => jest.fn().mockRejectedValue(value);\n rejectWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockRejectedValue(mock.a(props));\n req = {\n id: (id: Id): Req => new Req({ id }),\n q: (q: unknown): Req => new Req({ q }),\n with: (a: Json): Req => new Req(a),\n body: (body: unknown): Req => new Req({ body }),\n path: (path: Json): Req => new Req({ path }),\n query: (query: Json): Req => new Req({ query }),\n };\n resp = {\n items: (status: HttpStatus, items: unknown[] = []): Response => ({\n status: status,\n body: {\n data: {\n code: status.id as number,\n itemCount: items.length,\n items,\n },\n },\n }),\n errors: (status: HttpStatus, message: string, errors: unknown[] = []): Response => ({\n status: status,\n body: {\n error: {\n code: status.id as number,\n message: message,\n errorCount: errors.length,\n errors,\n },\n },\n }),\n };\n resolve = (value?: unknown): jest.Mock => jest.fn().mockResolvedValue(value);\n resolveWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockResolvedValue(mock.a(props));\n return = (value?: unknown): jest.Mock => jest.fn().mockReturnValue(value);\n returnWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockReturnValue(mock.a(props));\n this = (): jest.Mock => jest.fn().mockReturnThis();\n provider = {\n data: (...items: any[]): { execute: jest.Mock } => ({\n execute: jest.fn().mockResolvedValue({\n body: {\n data: {\n itemCount: items.length,\n items,\n },\n },\n }),\n }),\n };\n empty = <T = any>(props: Partial<T> = {}): T => props as T;\n a = this.empty;\n an = this.empty;\n date = (epoch = 1621347575): Date => {\n const date = new Date(epoch);\n date.toString = mock.return('Mon Jan 19 1970 19:22:27 GMT+0100 (Central European Standard Time)');\n date.toLocaleDateString = mock.return('19/01/1970');\n date.toDateString = mock.return('19/01/1970');\n return date;\n };\n once = (...values: unknown[]): jest.Mock => values.reduce((m: jest.Mock, v: unknown) => m.mockImplementationOnce(() => v), jest.fn());\n}\n\nexport const mock = new Mocks();\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/mock/Mocks.ts"],"sourcesContent":["import { Id, Json } from '../utils/Types';\nimport { Req } from '../utils/Req';\nimport { HttpStatus, Response } from '../utils/Response';\n\nexport class Mocks {\n clear = (): typeof jest => jest.clearAllMocks();\n impl = (f?: (...args: any[]) => any): jest.Mock => jest.fn().mockImplementation(f);\n property = <T extends object, P extends jest.NonFunctionPropertyNames<Required<T>>>(object: T, getter: P, value: T[P]): jest.SpyInstance =>\n jest.spyOn(object, getter, 'get' as jest.PropertyAccessors<P, T>).mockReturnValue(value as any);\n reject = (value?: unknown): jest.Mock => jest.fn().mockRejectedValue(value);\n rejectWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockRejectedValue(mock.a(props));\n req = {\n id: (id: Id): Req => new Req({ id }),\n q: (q: unknown): Req => new Req({ q }),\n with: (a: Json): Req => new Req(a),\n body: (body: unknown): Req => new Req({ body }),\n path: (path: Json): Req => new Req({ path }),\n query: (query: Json): Req => new Req({ query }),\n };\n resp = {\n items: (status: HttpStatus, items: unknown[] = []): Response => ({\n status: status,\n body: {\n data: {\n code: status.id as number,\n itemCount: items.length,\n items,\n },\n },\n }),\n errors: (status: HttpStatus, message: string, errors: unknown[] = []): Response => ({\n status: status,\n body: {\n error: {\n code: status.id as number,\n message: message,\n errorCount: errors.length,\n errors,\n },\n },\n }),\n };\n resolve = (value?: unknown): jest.Mock => jest.fn().mockResolvedValue(value);\n resolveWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockResolvedValue(mock.a(props));\n return = (value?: unknown): jest.Mock => jest.fn().mockReturnValue(value);\n returnWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockReturnValue(mock.a(props));\n this = (): jest.Mock => jest.fn().mockReturnThis();\n provider = {\n data: (...items: any[]): { execute: jest.Mock } => ({\n execute: jest.fn().mockResolvedValue({\n body: {\n data: {\n itemCount: items.length,\n items,\n },\n },\n }),\n }),\n };\n empty = <T = any>(props: Partial<T> = {}): T => props as T;\n a = this.empty;\n an = this.empty;\n date = (epoch = 1621347575): Date => {\n const date = new Date(epoch);\n date.toString = mock.return('Mon Jan 19 1970 19:22:27 GMT+0100 (Central European Standard Time)');\n date.toLocaleDateString = mock.return('19/01/1970');\n date.toDateString = mock.return('19/01/1970');\n return date;\n };\n once = (...values: unknown[]): jest.Mock => values.reduce((m: jest.Mock, v: unknown) => m.mockImplementationOnce(() => v), jest.fn());\n}\n\nexport const mock = new Mocks();\n"],"mappings":";;;;;;AAIO,IAAM,QAAN,MAAY;AAAA,EACjB,QAAQ,MAAmB,KAAK,cAAc;AAAA,EAC9C,OAAO,CAAC,MAA2C,KAAK,GAAG,EAAE,mBAAmB,CAAC;AAAA,EACjF,WAAW,CAAyE,QAAW,QAAW,UACxG,KAAK,MAAM,QAAQ,QAAQ,KAAqC,EAAE,gBAAgB,KAAY;AAAA,EAChG,SAAS,CAAC,UAA+B,KAAK,GAAG,EAAE,kBAAkB,KAAK;AAAA,EAC1E,aAAa,CAAU,QAAoB,CAAC,MAAiB,KAAK,GAAG,EAAE,kBAAkB,KAAK,EAAE,KAAK,CAAC;AAAA,EACtG,MAAM;AAAA,IACJ,IAAI,CAAC,OAAgB,IAAI,IAAI,EAAE,GAAG,CAAC;AAAA,IACnC,GAAG,CAAC,MAAoB,IAAI,IAAI,EAAE,EAAE,CAAC;AAAA,IACrC,MAAM,CAAC,MAAiB,IAAI,IAAI,CAAC;AAAA,IACjC,MAAM,CAAC,SAAuB,IAAI,IAAI,EAAE,KAAK,CAAC;AAAA,IAC9C,MAAM,CAAC,SAAoB,IAAI,IAAI,EAAE,KAAK,CAAC;AAAA,IAC3C,OAAO,CAAC,UAAqB,IAAI,IAAI,EAAE,MAAM,CAAC;AAAA,EAChD;AAAA,EACA,OAAO;AAAA,IACL,OAAO,CAAC,QAAoB,QAAmB,CAAC,OAAiB;AAAA,MAC/D;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,UACJ,MAAM,OAAO;AAAA,UACb,WAAW,MAAM;AAAA,UACjB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ,CAAC,QAAoB,SAAiB,SAAoB,CAAC,OAAiB;AAAA,MAClF;AAAA,MACA,MAAM;AAAA,QACJ,OAAO;AAAA,UACL,MAAM,OAAO;AAAA,UACb;AAAA,UACA,YAAY,OAAO;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,UAAU,CAAC,UAA+B,KAAK,GAAG,EAAE,kBAAkB,KAAK;AAAA,EAC3E,cAAc,CAAU,QAAoB,CAAC,MAAiB,KAAK,GAAG,EAAE,kBAAkB,KAAK,EAAE,KAAK,CAAC;AAAA,EACvG,SAAS,CAAC,UAA+B,KAAK,GAAG,EAAE,gBAAgB,KAAK;AAAA,EACxE,aAAa,CAAU,QAAoB,CAAC,MAAiB,KAAK,GAAG,EAAE,gBAAgB,KAAK,EAAE,KAAK,CAAC;AAAA,EACpG,OAAO,MAAiB,KAAK,GAAG,EAAE,eAAe;AAAA,EACjD,WAAW;AAAA,IACT,MAAM,IAAI,WAA0C;AAAA,MAClD,SAAS,KAAK,GAAG,EAAE,kBAAkB;AAAA,QACnC,MAAM;AAAA,UACJ,MAAM;AAAA,YACJ,WAAW,MAAM;AAAA,YACjB;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,QAAQ,CAAU,QAAoB,CAAC,MAAS;AAAA,EAChD,IAAI,KAAK;AAAA,EACT,KAAK,KAAK;AAAA,EACV,OAAO,CAAC,QAAQ,eAAqB;AACnC,UAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAK,WAAW,KAAK,OAAO,oEAAoE;AAChG,SAAK,qBAAqB,KAAK,OAAO,YAAY;AAClD,SAAK,eAAe,KAAK,OAAO,YAAY;AAC5C,WAAO;AAAA,EACT;AAAA,EACA,OAAO,IAAI,WAAiC,OAAO,OAAO,CAAC,GAAc,MAAe,EAAE,uBAAuB,MAAM,CAAC,GAAG,KAAK,GAAG,CAAC;AACtI;AAEO,IAAM,OAAO,IAAI,MAAM;","names":[]}
|
package/dist/utils/Eq.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
subset: (a, b) => equals(a, b, [iterableEquality, subsetEquality]),
|
|
6
|
-
string: (a, b) => asString(a) === asString(b)
|
|
7
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
eq
|
|
3
|
+
} from "../chunk-QE3TR4BY.mjs";
|
|
4
|
+
import "../chunk-O475TEG2.mjs";
|
|
8
5
|
export {
|
|
9
6
|
eq
|
|
10
7
|
};
|
package/dist/utils/Eq.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/Req.mjs
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
this.skip = isDefined(this.query?.skip) ? asNumber(this.query?.skip) : void 0;
|
|
6
|
-
this.take = isDefined(this.query?.take) ? asNumber(this.query?.take) : void 0;
|
|
7
|
-
}
|
|
8
|
-
skip;
|
|
9
|
-
take;
|
|
10
|
-
get id() {
|
|
11
|
-
return this.state.id ?? this.path.id;
|
|
12
|
-
}
|
|
13
|
-
get q() {
|
|
14
|
-
return this.state.q ?? this.query.q;
|
|
15
|
-
}
|
|
16
|
-
get path() {
|
|
17
|
-
return this.state?.path ?? {};
|
|
18
|
-
}
|
|
19
|
-
get query() {
|
|
20
|
-
return this.state?.query ?? {};
|
|
21
|
-
}
|
|
22
|
-
get body() {
|
|
23
|
-
return this.state.body;
|
|
24
|
-
}
|
|
25
|
-
get headers() {
|
|
26
|
-
return this.state.headers;
|
|
27
|
-
}
|
|
28
|
-
get = (key) => this?.state[key.toString()] ?? this.path[key.toString()] ?? this.query[key.toString()];
|
|
29
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
Req
|
|
3
|
+
} from "../chunk-KAVJOG5T.mjs";
|
|
4
|
+
import "../chunk-O475TEG2.mjs";
|
|
30
5
|
export {
|
|
31
6
|
Req
|
|
32
7
|
};
|
package/dist/utils/Req.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/Types.mjs
CHANGED
package/dist/utils/Types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/Utils.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
const toArray = (...items) => items.length > 1 ? items : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];
|
|
1
|
+
import {
|
|
2
|
+
asJson,
|
|
3
|
+
asNumber,
|
|
4
|
+
asString,
|
|
5
|
+
isA,
|
|
6
|
+
isAn,
|
|
7
|
+
isArray,
|
|
8
|
+
isDefined,
|
|
9
|
+
isFunction,
|
|
10
|
+
isNumber,
|
|
11
|
+
isObject,
|
|
12
|
+
toArray
|
|
13
|
+
} from "../chunk-O475TEG2.mjs";
|
|
15
14
|
export {
|
|
16
15
|
asJson,
|
|
17
16
|
asNumber,
|
package/dist/utils/Utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy-test",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.27.0",
|
|
4
4
|
"description": "Straightforward library for testing microservices built with @thisisagile/easy",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.mjs",
|
|
9
|
-
"types": "dist/index",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git@github.com:thisisagile/easy.git"
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"test": "yarn g:jest --coverage",
|
|
28
28
|
"prepack": "yarn g:copy-readme"
|
|
29
29
|
},
|
|
30
|
+
"sideEffects": false,
|
|
30
31
|
"files": [
|
|
31
32
|
"dist",
|
|
32
33
|
"src"
|
package/dist/matchers/Check.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var Check_exports = {};
|
|
20
|
-
__export(Check_exports, {
|
|
21
|
-
check: () => check,
|
|
22
|
-
checkDefined: () => checkDefined
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(Check_exports);
|
|
25
|
-
var import_Utils = require("../utils/Utils");
|
|
26
|
-
class Check {
|
|
27
|
-
constructor(ctx, received, expected, failed = false, message = "") {
|
|
28
|
-
this.ctx = ctx;
|
|
29
|
-
this.received = received;
|
|
30
|
-
this.expected = expected;
|
|
31
|
-
this.failed = failed;
|
|
32
|
-
this.message = message;
|
|
33
|
-
}
|
|
34
|
-
print(message) {
|
|
35
|
-
return (typeof message === "function" ? message([this.received, this.expected]) : message).replace("{r}", this.ctx.utils.printReceived(this.received)).replace("{e}", this.ctx.utils.printExpected(this.expected)).replace("{diff}", this.ctx.utils.diff(this.received, this.expected) ?? "");
|
|
36
|
-
}
|
|
37
|
-
not(p, message) {
|
|
38
|
-
if (this.failed) {
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
return new Check(this.ctx, this.received, this.expected, !p([this.received, this.expected]), this.print(message));
|
|
43
|
-
} catch (e) {
|
|
44
|
-
return new Check(this.ctx, this.received, this.expected, true, e.message);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
undefined(p, message) {
|
|
48
|
-
return this.not(() => (0, import_Utils.isDefined)(p([this.received, this.expected])), this.print(message));
|
|
49
|
-
}
|
|
50
|
-
else(message = "Expected {r} not to match with {e}, but it did.") {
|
|
51
|
-
return {
|
|
52
|
-
pass: !this.failed,
|
|
53
|
-
message: () => this.failed ? this.message : this.print(message)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const check = (ctx, received, expected) => new Check(ctx, received, expected);
|
|
58
|
-
const checkDefined = (ctx, received, expected) => new Check(ctx, received, expected).undefined(([r]) => r, "Received array is undefined.").undefined(([, e]) => e, "Expected array is undefined.");
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
check,
|
|
62
|
-
checkDefined
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=Check.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers/Check.ts"],"sourcesContent":["import { isDefined } from '../utils/Utils';\n\ntype ToMessage<S> = string | ((s: S[]) => string);\n\nclass Check<S> {\n constructor(\n private ctx: jest.MatcherContext,\n private readonly received: S,\n private readonly expected: S,\n private readonly failed = false,\n private readonly message = ''\n ) {}\n\n print(message: ToMessage<S>): string {\n return (typeof message === 'function' ? message([this.received, this.expected]) : message)\n .replace('{r}', this.ctx.utils.printReceived(this.received))\n .replace('{e}', this.ctx.utils.printExpected(this.expected))\n .replace('{diff}', this.ctx.utils.diff(this.received, this.expected) ?? '');\n }\n\n not(p: (s: S[]) => boolean, message: ToMessage<S>): Check<S> {\n if (this.failed) {\n return this;\n }\n try {\n return new Check<S>(this.ctx, this.received, this.expected, !p([this.received, this.expected]), this.print(message));\n } catch (e: any) {\n return new Check<S>(this.ctx, this.received, this.expected, true, e.message);\n }\n }\n\n undefined(p: (s: S[]) => any, message: ToMessage<S>): Check<S> {\n return this.not(() => isDefined(p([this.received, this.expected])), this.print(message));\n }\n\n else(message: ToMessage<S> = 'Expected {r} not to match with {e}, but it did.'): jest.CustomMatcherResult {\n return {\n pass: !this.failed,\n message: () => (this.failed ? this.message : this.print(message)),\n };\n }\n}\n\nexport const check = <S>(ctx: jest.MatcherContext, received: S, expected?: S): Check<S> => new Check<S>(ctx, received, expected as S);\n\nexport const checkDefined = <S>(ctx: jest.MatcherContext, received: S, expected?: S): Check<S> =>\n new Check<S>(ctx, received, expected as S).undefined(([r]) => r, 'Received array is undefined.').undefined(([, e]) => e, 'Expected array is undefined.');\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAI1B,MAAM,MAAS;AAAA,EACb,YACU,KACS,UACA,UACA,SAAS,OACT,UAAU,IAC3B;AALQ;AACS;AACA;AACA;AACA;AAAA,EAChB;AAAA,EAEH,MAAM,SAA+B;AACnC,YAAQ,OAAO,YAAY,aAAa,QAAQ,CAAC,KAAK,UAAU,KAAK,QAAQ,CAAC,IAAI,SAC/E,QAAQ,OAAO,KAAK,IAAI,MAAM,cAAc,KAAK,QAAQ,CAAC,EAC1D,QAAQ,OAAO,KAAK,IAAI,MAAM,cAAc,KAAK,QAAQ,CAAC,EAC1D,QAAQ,UAAU,KAAK,IAAI,MAAM,KAAK,KAAK,UAAU,KAAK,QAAQ,KAAK,EAAE;AAAA,EAC9E;AAAA,EAEA,IAAI,GAAwB,SAAiC;AAC3D,QAAI,KAAK,QAAQ;AACf,aAAO;AAAA,IACT;AACA,QAAI;AACF,aAAO,IAAI,MAAS,KAAK,KAAK,KAAK,UAAU,KAAK,UAAU,CAAC,EAAE,CAAC,KAAK,UAAU,KAAK,QAAQ,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC;AAAA,IACrH,SAAS,GAAQ;AACf,aAAO,IAAI,MAAS,KAAK,KAAK,KAAK,UAAU,KAAK,UAAU,MAAM,EAAE,OAAO;AAAA,IAC7E;AAAA,EACF;AAAA,EAEA,UAAU,GAAoB,SAAiC;AAC7D,WAAO,KAAK,IAAI,UAAM,wBAAU,EAAE,CAAC,KAAK,UAAU,KAAK,QAAQ,CAAC,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC;AAAA,EACzF;AAAA,EAEA,KAAK,UAAwB,mDAA6E;AACxG,WAAO;AAAA,MACL,MAAM,CAAC,KAAK;AAAA,MACZ,SAAS,MAAO,KAAK,SAAS,KAAK,UAAU,KAAK,MAAM,OAAO;AAAA,IACjE;AAAA,EACF;AACF;AAEO,MAAM,QAAQ,CAAI,KAA0B,UAAa,aAA2B,IAAI,MAAS,KAAK,UAAU,QAAa;AAE7H,MAAM,eAAe,CAAI,KAA0B,UAAa,aACrE,IAAI,MAAS,KAAK,UAAU,QAAa,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,GAAG,8BAA8B,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,8BAA8B;","names":[]}
|