@thisisagile/easy-test 19.1.3 → 20.0.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/index.d.ts +24 -2
- package/dist/index.js +22 -618
- package/dist/matchers/Check.d.ts +13 -10
- package/dist/matchers/Check.js +42 -0
- package/dist/matchers/Check.js.map +1 -0
- package/dist/matchers/HttpMatchers.d.ts +19 -16
- package/dist/matchers/HttpMatchers.js +32 -0
- package/dist/matchers/HttpMatchers.js.map +1 -0
- package/dist/matchers/Match.d.ts +11 -8
- package/dist/matchers/Match.js +35 -0
- package/dist/matchers/Match.js.map +1 -0
- package/dist/matchers/ResultMatchers.d.ts +10 -7
- package/dist/matchers/ResultMatchers.js +18 -0
- package/dist/matchers/ResultMatchers.js.map +1 -0
- package/dist/matchers/index.d.ts +20 -19
- package/dist/matchers/index.js +20 -0
- package/dist/matchers/toBeArrayOf.d.ts +9 -6
- package/dist/matchers/toBeArrayOf.js +8 -0
- package/dist/matchers/toBeArrayOf.js.map +1 -0
- package/dist/matchers/toBeArrayOfWithLength.d.ts +9 -6
- package/dist/matchers/toBeArrayOfWithLength.js +8 -0
- package/dist/matchers/toBeArrayOfWithLength.js.map +1 -0
- package/dist/matchers/toBeAt.d.ts +8 -5
- package/dist/matchers/toBeAt.js +10 -0
- package/dist/matchers/toBeAt.js.map +1 -0
- package/dist/matchers/toBeExactlyAt.d.ts +8 -5
- package/dist/matchers/toBeExactlyAt.js +15 -0
- package/dist/matchers/toBeExactlyAt.js.map +1 -0
- package/dist/matchers/toBeQueriedWith.d.ts +8 -5
- package/dist/matchers/toBeQueriedWith.js +8 -0
- package/dist/matchers/toBeQueriedWith.js.map +1 -0
- package/dist/matchers/toBeRoutedTo.d.ts +8 -5
- package/dist/matchers/toBeRoutedTo.js +14 -0
- package/dist/matchers/toBeRoutedTo.js.map +1 -0
- package/dist/matchers/toBeValid.d.ts +7 -4
- package/dist/matchers/toBeValid.js +9 -0
- package/dist/matchers/toBeValid.js.map +1 -0
- package/dist/matchers/toFailMatcher.d.ts +13 -10
- package/dist/matchers/toFailMatcher.js +21 -0
- package/dist/matchers/toFailMatcher.js.map +1 -0
- package/dist/matchers/toMatchArray.d.ts +7 -4
- package/dist/matchers/toMatchArray.js +10 -0
- package/dist/matchers/toMatchArray.js.map +1 -0
- package/dist/matchers/toMatchExactJson.d.ts +11 -8
- package/dist/matchers/toMatchExactJson.js +15 -0
- package/dist/matchers/toMatchExactJson.js.map +1 -0
- package/dist/matchers/toMatchException.d.ts +8 -5
- package/dist/matchers/toMatchException.js +9 -0
- package/dist/matchers/toMatchException.js.map +1 -0
- package/dist/matchers/toMatchJson.d.ts +11 -8
- package/dist/matchers/toMatchJson.js +16 -0
- package/dist/matchers/toMatchJson.js.map +1 -0
- package/dist/matchers/toMatchRoute.d.ts +8 -5
- package/dist/matchers/toMatchRoute.js +9 -0
- package/dist/matchers/toMatchRoute.js.map +1 -0
- package/dist/matchers/toMatchText.d.ts +7 -4
- package/dist/matchers/toMatchText.js +9 -0
- package/dist/matchers/toMatchText.js.map +1 -0
- package/dist/matchers/toPassMatcher.d.ts +13 -10
- package/dist/matchers/toPassMatcher.js +21 -0
- package/dist/matchers/toPassMatcher.js.map +1 -0
- package/dist/mock/Fits.d.ts +19 -16
- package/dist/mock/Fits.js +42 -0
- package/dist/mock/Fits.js.map +1 -0
- package/dist/mock/Mocks.d.ts +38 -35
- package/dist/mock/Mocks.js +68 -0
- package/dist/mock/Mocks.js.map +1 -0
- package/dist/mock/index.d.ts +3 -2
- package/dist/mock/index.js +3 -0
- package/dist/utils/Eq.d.ts +6 -3
- package/dist/utils/Eq.js +12 -0
- package/dist/utils/Eq.js.map +1 -0
- package/dist/utils/Req.d.ts +15 -12
- package/dist/utils/Req.js +35 -0
- package/dist/utils/Req.js.map +1 -0
- package/dist/utils/Response.d.ts +22 -19
- package/dist/utils/Response.js +0 -0
- package/dist/utils/Types.d.ts +18 -17
- package/dist/utils/Types.js +7 -0
- package/dist/utils/Types.js.map +1 -0
- package/dist/utils/Utils.d.ts +4 -1
- package/dist/utils/Utils.js +19 -0
- package/dist/utils/Utils.js.map +1 -0
- package/package.json +36 -34
- package/dist/chunk-6EKWTLNQ.mjs +0 -12
- package/dist/chunk-6EKWTLNQ.mjs.map +0 -1
- package/dist/chunk-6FEQASGO.mjs +0 -17
- package/dist/chunk-6FEQASGO.mjs.map +0 -1
- package/dist/chunk-ART72TJA.mjs +0 -25
- package/dist/chunk-ART72TJA.mjs.map +0 -1
- package/dist/chunk-BN2IG45X.mjs +0 -24
- package/dist/chunk-BN2IG45X.mjs.map +0 -1
- package/dist/chunk-BZXBZCMZ.mjs +0 -26
- package/dist/chunk-BZXBZCMZ.mjs.map +0 -1
- package/dist/chunk-CQPHLHB7.mjs +0 -86
- package/dist/chunk-CQPHLHB7.mjs.map +0 -1
- package/dist/chunk-DHDFXV7G.mjs +0 -53
- package/dist/chunk-DHDFXV7G.mjs.map +0 -1
- package/dist/chunk-DMSYYRBM.mjs +0 -59
- package/dist/chunk-DMSYYRBM.mjs.map +0 -1
- package/dist/chunk-EZNTPFD2.mjs +0 -39
- package/dist/chunk-EZNTPFD2.mjs.map +0 -1
- package/dist/chunk-GRYVDJXU.mjs +0 -1
- package/dist/chunk-GRYVDJXU.mjs.map +0 -1
- package/dist/chunk-LN24S2PC.mjs +0 -41
- package/dist/chunk-LN24S2PC.mjs.map +0 -1
- package/dist/chunk-MBQSBGEE.mjs +0 -1
- package/dist/chunk-MBQSBGEE.mjs.map +0 -1
- package/dist/chunk-O475TEG2.mjs +0 -30
- package/dist/chunk-O475TEG2.mjs.map +0 -1
- package/dist/chunk-PPXFT3SX.mjs +0 -14
- package/dist/chunk-PPXFT3SX.mjs.map +0 -1
- package/dist/chunk-QE3TR4BY.mjs +0 -16
- package/dist/chunk-QE3TR4BY.mjs.map +0 -1
- package/dist/chunk-QWLALNJL.mjs +0 -30
- package/dist/chunk-QWLALNJL.mjs.map +0 -1
- package/dist/chunk-RPYWAKYZ.mjs +0 -39
- package/dist/chunk-RPYWAKYZ.mjs.map +0 -1
- package/dist/chunk-SGV4XPW3.mjs +0 -27
- package/dist/chunk-SGV4XPW3.mjs.map +0 -1
- package/dist/chunk-SJR3TRWF.mjs +0 -39
- package/dist/chunk-SJR3TRWF.mjs.map +0 -1
- package/dist/chunk-TUE23FNE.mjs +0 -17
- package/dist/chunk-TUE23FNE.mjs.map +0 -1
- package/dist/chunk-UFDXFCRK.mjs +0 -19
- package/dist/chunk-UFDXFCRK.mjs.map +0 -1
- package/dist/chunk-UOO6EMXQ.mjs +0 -20
- package/dist/chunk-UOO6EMXQ.mjs.map +0 -1
- package/dist/chunk-WAKTWLNU.mjs +0 -32
- package/dist/chunk-WAKTWLNU.mjs.map +0 -1
- package/dist/chunk-YL7PRCYP.mjs +0 -26
- package/dist/chunk-YL7PRCYP.mjs.map +0 -1
- package/dist/chunk-Z4XAP66Q.mjs +0 -44
- package/dist/chunk-Z4XAP66Q.mjs.map +0 -1
- package/dist/chunk-Z6NXMCUL.mjs +0 -17
- package/dist/chunk-Z6NXMCUL.mjs.map +0 -1
- package/dist/chunk-ZBSBLFC7.mjs +0 -20
- package/dist/chunk-ZBSBLFC7.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -151
- package/dist/index.mjs.map +0 -1
- package/dist/matchers/Check.mjs +0 -10
- package/dist/matchers/Check.mjs.map +0 -1
- package/dist/matchers/HttpMatchers.mjs +0 -32
- package/dist/matchers/HttpMatchers.mjs.map +0 -1
- package/dist/matchers/Match.mjs +0 -11
- package/dist/matchers/Match.mjs.map +0 -1
- package/dist/matchers/ResultMatchers.mjs +0 -14
- package/dist/matchers/ResultMatchers.mjs.map +0 -1
- package/dist/matchers/index.mjs +0 -133
- package/dist/matchers/index.mjs.map +0 -1
- package/dist/matchers/toBeArrayOf.mjs +0 -10
- package/dist/matchers/toBeArrayOf.mjs.map +0 -1
- package/dist/matchers/toBeArrayOfWithLength.mjs +0 -10
- package/dist/matchers/toBeArrayOfWithLength.mjs.map +0 -1
- package/dist/matchers/toBeAt.mjs +0 -10
- package/dist/matchers/toBeAt.mjs.map +0 -1
- package/dist/matchers/toBeExactlyAt.mjs +0 -10
- package/dist/matchers/toBeExactlyAt.mjs.map +0 -1
- package/dist/matchers/toBeQueriedWith.mjs +0 -10
- package/dist/matchers/toBeQueriedWith.mjs.map +0 -1
- package/dist/matchers/toBeRoutedTo.mjs +0 -15
- package/dist/matchers/toBeRoutedTo.mjs.map +0 -1
- package/dist/matchers/toBeValid.mjs +0 -10
- package/dist/matchers/toBeValid.mjs.map +0 -1
- package/dist/matchers/toFailMatcher.mjs +0 -16
- package/dist/matchers/toFailMatcher.mjs.map +0 -1
- package/dist/matchers/toMatchArray.mjs +0 -9
- package/dist/matchers/toMatchArray.mjs.map +0 -1
- package/dist/matchers/toMatchExactJson.mjs +0 -13
- package/dist/matchers/toMatchExactJson.mjs.map +0 -1
- package/dist/matchers/toMatchException.mjs +0 -10
- package/dist/matchers/toMatchException.mjs.map +0 -1
- package/dist/matchers/toMatchJson.mjs +0 -13
- package/dist/matchers/toMatchJson.mjs.map +0 -1
- package/dist/matchers/toMatchRoute.mjs +0 -10
- package/dist/matchers/toMatchRoute.mjs.map +0 -1
- package/dist/matchers/toMatchText.mjs +0 -10
- package/dist/matchers/toMatchText.mjs.map +0 -1
- package/dist/matchers/toPassMatcher.mjs +0 -16
- package/dist/matchers/toPassMatcher.mjs.map +0 -1
- package/dist/mock/Fits.mjs +0 -15
- package/dist/mock/Fits.mjs.map +0 -1
- package/dist/mock/Mocks.mjs +0 -11
- package/dist/mock/Mocks.mjs.map +0 -1
- package/dist/mock/index.mjs +0 -23
- package/dist/mock/index.mjs.map +0 -1
- package/dist/utils/Eq.mjs +0 -8
- package/dist/utils/Eq.mjs.map +0 -1
- package/dist/utils/Req.mjs +0 -8
- package/dist/utils/Req.mjs.map +0 -1
- package/dist/utils/Response.mjs +0 -1
- package/dist/utils/Response.mjs.map +0 -1
- package/dist/utils/Types.mjs +0 -8
- package/dist/utils/Types.mjs.map +0 -1
- package/dist/utils/Utils.mjs +0 -27
- package/dist/utils/Utils.mjs.map +0 -1
package/dist/chunk-CQPHLHB7.mjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Req
|
|
3
|
-
} from "./chunk-SJR3TRWF.mjs";
|
|
4
|
-
|
|
5
|
-
// src/mock/Mocks.ts
|
|
6
|
-
var Mocks = class {
|
|
7
|
-
req = {
|
|
8
|
-
id: (id) => new Req({ id }),
|
|
9
|
-
q: (q) => new Req({ q }),
|
|
10
|
-
with: (a) => new Req(a),
|
|
11
|
-
body: (body) => new Req({ body }),
|
|
12
|
-
path: (path) => new Req({ path }),
|
|
13
|
-
query: (query) => new Req({ query })
|
|
14
|
-
};
|
|
15
|
-
resp = {
|
|
16
|
-
items: (status, items = []) => ({
|
|
17
|
-
status,
|
|
18
|
-
body: {
|
|
19
|
-
data: {
|
|
20
|
-
code: status.id,
|
|
21
|
-
itemCount: items.length,
|
|
22
|
-
items
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}),
|
|
26
|
-
errors: (status, message, errors = []) => ({
|
|
27
|
-
status,
|
|
28
|
-
body: {
|
|
29
|
-
error: {
|
|
30
|
-
code: status.id,
|
|
31
|
-
message,
|
|
32
|
-
errorCount: errors.length,
|
|
33
|
-
errors
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
};
|
|
38
|
-
provider = {
|
|
39
|
-
data: (...items) => ({
|
|
40
|
-
execute: jest.fn().mockResolvedValue({
|
|
41
|
-
body: {
|
|
42
|
-
data: {
|
|
43
|
-
itemCount: items.length,
|
|
44
|
-
items
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
};
|
|
50
|
-
static getArg = (mock2, call = 0, arg = 0) => {
|
|
51
|
-
if (!isJestMock(mock2))
|
|
52
|
-
throw new Error("Function provided is not a Jest mock");
|
|
53
|
-
return mock2.mock.calls[call]?.[arg];
|
|
54
|
-
};
|
|
55
|
-
clear = () => jest.clearAllMocks();
|
|
56
|
-
impl = (f) => jest.fn().mockImplementation(f);
|
|
57
|
-
property = (object, getter, value) => jest.spyOn(object, getter, "get").mockReturnValue(value);
|
|
58
|
-
reject = (value) => jest.fn().mockRejectedValue(value);
|
|
59
|
-
rejectWith = (props = {}) => jest.fn().mockRejectedValue(mock.a(props));
|
|
60
|
-
resolve = (value) => jest.fn().mockResolvedValue(value);
|
|
61
|
-
resolveWith = (props = {}) => jest.fn().mockResolvedValue(mock.a(props));
|
|
62
|
-
return = (value) => jest.fn().mockReturnValue(value);
|
|
63
|
-
returnWith = (props = {}) => jest.fn().mockReturnValue(mock.a(props));
|
|
64
|
-
this = () => jest.fn().mockReturnThis();
|
|
65
|
-
empty = (props = {}) => props;
|
|
66
|
-
a = this.empty;
|
|
67
|
-
an = this.empty;
|
|
68
|
-
date = (epoch = 1621347575) => {
|
|
69
|
-
const date = new Date(epoch);
|
|
70
|
-
date.toString = mock.return("Mon Jan 19 1970 19:22:27 GMT+0100 (Central European Standard Time)");
|
|
71
|
-
date.toLocaleDateString = mock.return("19/01/1970");
|
|
72
|
-
date.toDateString = mock.return("19/01/1970");
|
|
73
|
-
return date;
|
|
74
|
-
};
|
|
75
|
-
once = (...values) => values.reduce((m, v) => m.mockImplementationOnce(() => v), jest.fn());
|
|
76
|
-
};
|
|
77
|
-
function isJestMock(fn) {
|
|
78
|
-
return typeof fn === "function" && "mock" in fn && Array.isArray(fn.mock?.calls);
|
|
79
|
-
}
|
|
80
|
-
var mock = new Mocks();
|
|
81
|
-
|
|
82
|
-
export {
|
|
83
|
-
Mocks,
|
|
84
|
-
mock
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=chunk-CQPHLHB7.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 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: <B = unknown>(body: B): Req<B> => new Req<B>({ 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 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\n static readonly getArg = <T>(mock: unknown, call = 0, arg = 0): T | undefined => {\n if (!isJestMock(mock)) throw new Error('Function provided is not a Jest mock');\n return mock.mock.calls[call]?.[arg] as T;\n };\n\n clear = (): typeof jest => jest.clearAllMocks();\n\n impl = (f?: (...args: any[]) => any): jest.Mock => jest.fn().mockImplementation(f);\n\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\n reject = (value?: unknown): jest.Mock => jest.fn().mockRejectedValue(value);\n\n rejectWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockRejectedValue(mock.a(props));\n\n resolve = (value?: unknown): jest.Mock => jest.fn().mockResolvedValue(value);\n\n resolveWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockResolvedValue(mock.a(props));\n\n return = (value?: unknown): jest.Mock => jest.fn().mockReturnValue(value);\n\n returnWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockReturnValue(mock.a(props));\n\n this = (): jest.Mock => jest.fn().mockReturnThis();\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\nfunction isJestMock(fn: any): fn is jest.Mock {\n return typeof fn === 'function' && 'mock' in fn && Array.isArray(fn.mock?.calls);\n}\n\nexport const mock = new Mocks();\n"],"mappings":";;;;;AAIO,IAAM,QAAN,MAAY;AAAA,EACjB,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,SAAoB,IAAI,IAAO,EAAE,KAAK,CAAC;AAAA,IAC3D,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,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,EAEA,OAAgB,SAAS,CAAIA,OAAe,OAAO,GAAG,MAAM,MAAqB;AAC/E,QAAI,CAAC,WAAWA,KAAI;AAAG,YAAM,IAAI,MAAM,sCAAsC;AAC7E,WAAOA,MAAK,KAAK,MAAM,IAAI,IAAI,GAAG;AAAA,EACpC;AAAA,EAEA,QAAQ,MAAmB,KAAK,cAAc;AAAA,EAE9C,OAAO,CAAC,MAA2C,KAAK,GAAG,EAAE,mBAAmB,CAAC;AAAA,EAEjF,WAAW,CAAyE,QAAW,QAAW,UACxG,KAAK,MAAM,QAAQ,QAAQ,KAAqC,EAAE,gBAAgB,KAAY;AAAA,EAEhG,SAAS,CAAC,UAA+B,KAAK,GAAG,EAAE,kBAAkB,KAAK;AAAA,EAE1E,aAAa,CAAU,QAAoB,CAAC,MAAiB,KAAK,GAAG,EAAE,kBAAkB,KAAK,EAAE,KAAK,CAAC;AAAA,EAEtG,UAAU,CAAC,UAA+B,KAAK,GAAG,EAAE,kBAAkB,KAAK;AAAA,EAE3E,cAAc,CAAU,QAAoB,CAAC,MAAiB,KAAK,GAAG,EAAE,kBAAkB,KAAK,EAAE,KAAK,CAAC;AAAA,EAEvG,SAAS,CAAC,UAA+B,KAAK,GAAG,EAAE,gBAAgB,KAAK;AAAA,EAExE,aAAa,CAAU,QAAoB,CAAC,MAAiB,KAAK,GAAG,EAAE,gBAAgB,KAAK,EAAE,KAAK,CAAC;AAAA,EAEpG,OAAO,MAAiB,KAAK,GAAG,EAAE,eAAe;AAAA,EAEjD,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;AAEA,SAAS,WAAW,IAA0B;AAC5C,SAAO,OAAO,OAAO,cAAc,UAAU,MAAM,MAAM,QAAQ,GAAG,MAAM,KAAK;AACjF;AAEO,IAAM,OAAO,IAAI,MAAM;","names":["mock"]}
|
package/dist/chunk-DHDFXV7G.mjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
|
11
|
-
import { AsymmetricMatcher } from "expect";
|
|
12
|
-
var ObjectContainingText = class extends AsymmetricMatcher {
|
|
13
|
-
asymmetricMatch(other) {
|
|
14
|
-
return asString(other).includes(asString(this.sample));
|
|
15
|
-
}
|
|
16
|
-
toString() {
|
|
17
|
-
return `String${this.inverse ? "Not" : ""}Containing`;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var ObjectContainingTextExact = class extends AsymmetricMatcher {
|
|
21
|
-
asymmetricMatch(other) {
|
|
22
|
-
return asString(other) === asString(this.sample);
|
|
23
|
-
}
|
|
24
|
-
toString() {
|
|
25
|
-
return `String${this.inverse ? "Not" : ""}Containing`;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var ObjectContainingJson = class extends AsymmetricMatcher {
|
|
29
|
-
asymmetricMatch(other) {
|
|
30
|
-
return eq.subset(asJson(other), asJson(this.sample));
|
|
31
|
-
}
|
|
32
|
-
toString() {
|
|
33
|
-
return `Object${this.inverse ? "Not" : ""}Containing`;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var fits = {
|
|
37
|
-
any: () => expect.anything(),
|
|
38
|
-
type: (type) => expect.any(type),
|
|
39
|
-
with: (o) => expect.objectContaining(o),
|
|
40
|
-
text: (s) => new ObjectContainingText(s),
|
|
41
|
-
textExact: (s) => new ObjectContainingTextExact(s),
|
|
42
|
-
uri: (u) => fits.textExact(u),
|
|
43
|
-
json: (s) => new ObjectContainingJson(s),
|
|
44
|
-
items: (...items) => expect.arrayContaining(toArray(...items))
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
ObjectContainingText,
|
|
49
|
-
ObjectContainingTextExact,
|
|
50
|
-
ObjectContainingJson,
|
|
51
|
-
fits
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=chunk-DHDFXV7G.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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/chunk-DMSYYRBM.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
match
|
|
3
|
-
} from "./chunk-LN24S2PC.mjs";
|
|
4
|
-
|
|
5
|
-
// src/matchers/HttpMatchers.ts
|
|
6
|
-
var toHaveStatus = (res, code) => match(res).undefined((r) => r, "Response is unknown.").undefined(
|
|
7
|
-
(r) => r?.status?.id,
|
|
8
|
-
() => "Response does not have a status code"
|
|
9
|
-
).not(
|
|
10
|
-
(r) => r.status.id === code,
|
|
11
|
-
(r) => `Response does not have code '${code}', but has code '${r.status.id}' instead.`
|
|
12
|
-
).else(`Response does have status code '${code}'.`);
|
|
13
|
-
var toBeOk = (res) => toHaveStatus(res, 200);
|
|
14
|
-
var toBeCreated = (res) => toHaveStatus(res, 201);
|
|
15
|
-
var toHaveNoContent = (res) => toHaveStatus(res, 204);
|
|
16
|
-
var toBeBadRequest = (res) => toHaveStatus(res, 400);
|
|
17
|
-
var toBeUnauthorized = (res) => toHaveStatus(res, 401);
|
|
18
|
-
var toBeForbidden = (res) => toHaveStatus(res, 403);
|
|
19
|
-
var toBeNotFound = (res) => toHaveStatus(res, 404);
|
|
20
|
-
var toBeConflict = (res) => toHaveStatus(res, 409);
|
|
21
|
-
var toBeInternalServerError = (res) => toHaveStatus(res, 500);
|
|
22
|
-
var toBeBadGateway = (res) => toHaveStatus(res, 502);
|
|
23
|
-
var toBeOkWithItems = (res, length) => match(res).undefined((r) => r.status?.id, "Response did not have a status").not(
|
|
24
|
-
(r) => r.status.id === 200,
|
|
25
|
-
(r) => `Response did not have status '200'. It had status '${r.status.id}' instead.`
|
|
26
|
-
).undefined((r) => r?.body?.data?.items, `Response did not have any items.`).not(
|
|
27
|
-
(r) => (r?.body?.data?.itemCount ?? 0) >= length,
|
|
28
|
-
(r) => `Response did not have at least ${length} items. It only had ${r?.body?.data?.itemCount ?? 0} items.`
|
|
29
|
-
).else(`Response had status 200 and at least ${length} items`);
|
|
30
|
-
expect.extend({
|
|
31
|
-
toBeOk,
|
|
32
|
-
toBeOkWithItems,
|
|
33
|
-
toBeCreated,
|
|
34
|
-
toHaveNoContent,
|
|
35
|
-
toBeNotFound,
|
|
36
|
-
toBeBadRequest,
|
|
37
|
-
toBeUnauthorized,
|
|
38
|
-
toBeForbidden,
|
|
39
|
-
toBeConflict,
|
|
40
|
-
toBeInternalServerError,
|
|
41
|
-
toHaveStatus,
|
|
42
|
-
toBeBadGateway
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
toHaveStatus,
|
|
47
|
-
toBeOk,
|
|
48
|
-
toBeCreated,
|
|
49
|
-
toHaveNoContent,
|
|
50
|
-
toBeBadRequest,
|
|
51
|
-
toBeUnauthorized,
|
|
52
|
-
toBeForbidden,
|
|
53
|
-
toBeNotFound,
|
|
54
|
-
toBeConflict,
|
|
55
|
-
toBeInternalServerError,
|
|
56
|
-
toBeBadGateway,
|
|
57
|
-
toBeOkWithItems
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=chunk-DMSYYRBM.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matchers/HttpMatchers.ts"],"sourcesContent":["import { Response } from '../utils/Response';\nimport { match } from './Match';\n\nexport const toHaveStatus = (res: Response, code: number): jest.CustomMatcherResult =>\n match<Response>(res)\n .undefined(r => r, 'Response is unknown.')\n .undefined(\n r => r?.status?.id,\n () => 'Response does not have a status code'\n )\n .not(\n r => r.status.id === code,\n r => `Response does not have code '${code}', but has code '${r.status.id}' instead.`\n )\n .else(`Response does have status code '${code}'.`);\n\nexport const toBeOk = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 200);\n\nexport const toBeCreated = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 201);\n\nexport const toHaveNoContent = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 204);\n\nexport const toBeBadRequest = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 400);\n\nexport const toBeUnauthorized = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 401);\n\nexport const toBeForbidden = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 403);\n\nexport const toBeNotFound = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 404);\n\nexport const toBeConflict = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 409);\n\nexport const toBeInternalServerError = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 500);\n\nexport const toBeBadGateway = (res: Response): jest.CustomMatcherResult => toHaveStatus(res, 502);\n\nexport const toBeOkWithItems = (res: Response, length: number): jest.CustomMatcherResult =>\n match<Response>(res)\n .undefined(r => r.status?.id, 'Response did not have a status')\n .not(\n r => r.status.id === 200,\n r => `Response did not have status '200'. It had status '${r.status.id}' instead.`\n )\n .undefined(r => r?.body?.data?.items, `Response did not have any items.`)\n .not(\n r => (r?.body?.data?.itemCount ?? 0) >= length,\n r => `Response did not have at least ${length} items. It only had ${r?.body?.data?.itemCount ?? 0} items.`\n )\n .else(`Response had status 200 and at least ${length} items`);\n\nexpect.extend({\n toBeOk,\n toBeOkWithItems,\n toBeCreated,\n toHaveNoContent,\n toBeNotFound,\n toBeBadRequest,\n toBeUnauthorized,\n toBeForbidden,\n toBeConflict,\n toBeInternalServerError,\n toHaveStatus,\n toBeBadGateway,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeOk(): R;\n toBeOkWithItems(length: number): R;\n toBeCreated(): R;\n toHaveNoContent(): R;\n toBeNotFound(): R;\n toBeUnauthorized(): R;\n toBeForbidden(): R;\n toBeBadRequest(): R;\n toBeConflict(): R;\n toBeInternalServerError(): R;\n toBeBadGateway(): R;\n toHaveStatus(code: number): R;\n }\n }\n}\n"],"mappings":";;;;;AAGO,IAAM,eAAe,CAAC,KAAe,SAC1C,MAAgB,GAAG,EAChB,UAAU,OAAK,GAAG,sBAAsB,EACxC;AAAA,EACC,OAAK,GAAG,QAAQ;AAAA,EAChB,MAAM;AACR,EACC;AAAA,EACC,OAAK,EAAE,OAAO,OAAO;AAAA,EACrB,OAAK,gCAAgC,IAAI,oBAAoB,EAAE,OAAO,EAAE;AAC1E,EACC,KAAK,mCAAmC,IAAI,IAAI;AAE9C,IAAM,SAAS,CAAC,QAA4C,aAAa,KAAK,GAAG;AAEjF,IAAM,cAAc,CAAC,QAA4C,aAAa,KAAK,GAAG;AAEtF,IAAM,kBAAkB,CAAC,QAA4C,aAAa,KAAK,GAAG;AAE1F,IAAM,iBAAiB,CAAC,QAA4C,aAAa,KAAK,GAAG;AAEzF,IAAM,mBAAmB,CAAC,QAA4C,aAAa,KAAK,GAAG;AAE3F,IAAM,gBAAgB,CAAC,QAA4C,aAAa,KAAK,GAAG;AAExF,IAAM,eAAe,CAAC,QAA4C,aAAa,KAAK,GAAG;AAEvF,IAAM,eAAe,CAAC,QAA4C,aAAa,KAAK,GAAG;AAEvF,IAAM,0BAA0B,CAAC,QAA4C,aAAa,KAAK,GAAG;AAElG,IAAM,iBAAiB,CAAC,QAA4C,aAAa,KAAK,GAAG;AAEzF,IAAM,kBAAkB,CAAC,KAAe,WAC7C,MAAgB,GAAG,EAChB,UAAU,OAAK,EAAE,QAAQ,IAAI,gCAAgC,EAC7D;AAAA,EACC,OAAK,EAAE,OAAO,OAAO;AAAA,EACrB,OAAK,sDAAsD,EAAE,OAAO,EAAE;AACxE,EACC,UAAU,OAAK,GAAG,MAAM,MAAM,OAAO,kCAAkC,EACvE;AAAA,EACC,QAAM,GAAG,MAAM,MAAM,aAAa,MAAM;AAAA,EACxC,OAAK,kCAAkC,MAAM,uBAAuB,GAAG,MAAM,MAAM,aAAa,CAAC;AACnG,EACC,KAAK,wCAAwC,MAAM,QAAQ;AAEhE,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":[]}
|
package/dist/chunk-EZNTPFD2.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
match
|
|
3
|
-
} from "./chunk-LN24S2PC.mjs";
|
|
4
|
-
import {
|
|
5
|
-
toMessage
|
|
6
|
-
} from "./chunk-6EKWTLNQ.mjs";
|
|
7
|
-
|
|
8
|
-
// src/matchers/toFailMatcher.ts
|
|
9
|
-
var Fails = {
|
|
10
|
-
Yes: "Match fails, instead of passes.",
|
|
11
|
-
No: (reason) => `Match doesn't fail, because '${reason}'`
|
|
12
|
-
};
|
|
13
|
-
var FailsWith = {
|
|
14
|
-
Yes: "Match fails with correct message.",
|
|
15
|
-
No: (message, instead) => `Match does fail, however not with message '${message}', but with message '${instead}' instead.`
|
|
16
|
-
};
|
|
17
|
-
var toFailMatcher = (result) => match(result).not(
|
|
18
|
-
(c) => !c.pass,
|
|
19
|
-
(c) => Fails.No(c.message())
|
|
20
|
-
).else(Fails.Yes);
|
|
21
|
-
var toFailMatcherWith = (result, message) => match(result).not(
|
|
22
|
-
(c) => !c.pass,
|
|
23
|
-
(c) => Fails.No(c.message())
|
|
24
|
-
).not(
|
|
25
|
-
(c) => c.message().includes(toMessage(message)),
|
|
26
|
-
(c) => FailsWith.No(toMessage(message), c.message())
|
|
27
|
-
).else(FailsWith.Yes);
|
|
28
|
-
expect.extend({
|
|
29
|
-
toFailMatcher,
|
|
30
|
-
toFailMatcherWith
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
Fails,
|
|
35
|
-
FailsWith,
|
|
36
|
-
toFailMatcher,
|
|
37
|
-
toFailMatcherWith
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=chunk-EZNTPFD2.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matchers/toFailMatcher.ts"],"sourcesContent":["import { match } from './Match';\nimport { Message, toMessage } from '../utils/Types';\n\n// Handles CustomMatcherResult validations.\n\nexport const Fails = {\n Yes: 'Match fails, instead of passes.',\n No: (reason: string): string => `Match doesn't fail, because '${reason}'`,\n};\n\nexport const FailsWith = {\n Yes: 'Match fails with correct message.',\n No: (message: string, instead: string): string => `Match does fail, however not with message '${message}', but with message '${instead}' instead.`,\n};\n\nexport const toFailMatcher = (result: jest.CustomMatcherResult): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => !c.pass,\n c => Fails.No(c.message())\n )\n .else(Fails.Yes);\n\nexport const toFailMatcherWith = (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => !c.pass,\n c => Fails.No(c.message())\n )\n .not(\n c => c.message().includes(toMessage(message)),\n c => FailsWith.No(toMessage(message), c.message())\n )\n .else(FailsWith.Yes);\n\nexpect.extend({\n toFailMatcher: toFailMatcher,\n toFailMatcherWith: toFailMatcherWith,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toFailMatcher(): R;\n\n toFailMatcherWith(message: string): R;\n }\n }\n}\n"],"mappings":";;;;;;;;AAKO,IAAM,QAAQ;AAAA,EACnB,KAAK;AAAA,EACL,IAAI,CAAC,WAA2B,gCAAgC,MAAM;AACxE;AAEO,IAAM,YAAY;AAAA,EACvB,KAAK;AAAA,EACL,IAAI,CAAC,SAAiB,YAA4B,8CAA8C,OAAO,wBAAwB,OAAO;AACxI;AAEO,IAAM,gBAAgB,CAAC,WAC5B,MAAM,MAAM,EACT;AAAA,EACC,OAAK,CAAC,EAAE;AAAA,EACR,OAAK,MAAM,GAAG,EAAE,QAAQ,CAAC;AAC3B,EACC,KAAK,MAAM,GAAG;AAEZ,IAAM,oBAAoB,CAAC,QAAkC,YAClE,MAAM,MAAM,EACT;AAAA,EACC,OAAK,CAAC,EAAE;AAAA,EACR,OAAK,MAAM,GAAG,EAAE,QAAQ,CAAC;AAC3B,EACC;AAAA,EACC,OAAK,EAAE,QAAQ,EAAE,SAAS,UAAU,OAAO,CAAC;AAAA,EAC5C,OAAK,UAAU,GAAG,UAAU,OAAO,GAAG,EAAE,QAAQ,CAAC;AACnD,EACC,KAAK,UAAU,GAAG;AAEvB,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AACF,CAAC;","names":[]}
|
package/dist/chunk-GRYVDJXU.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-GRYVDJXU.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-LN24S2PC.mjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toMessage
|
|
3
|
-
} from "./chunk-6EKWTLNQ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
isDefined
|
|
6
|
-
} from "./chunk-O475TEG2.mjs";
|
|
7
|
-
|
|
8
|
-
// src/matchers/Match.ts
|
|
9
|
-
var Match = class _Match {
|
|
10
|
-
constructor(subject, failed = false, message = "") {
|
|
11
|
-
this.subject = subject;
|
|
12
|
-
this.failed = failed;
|
|
13
|
-
this.message = message;
|
|
14
|
-
}
|
|
15
|
-
not(p, message) {
|
|
16
|
-
if (this.failed) {
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
return new _Match(this.subject, !p(this.subject), toMessage(message, this.subject));
|
|
21
|
-
} catch (e) {
|
|
22
|
-
return new _Match(this.subject, true, e.message);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
undefined(p, message) {
|
|
26
|
-
return this.not(() => isDefined(p(this.subject)), message);
|
|
27
|
-
}
|
|
28
|
-
else(message) {
|
|
29
|
-
return {
|
|
30
|
-
pass: !this.failed,
|
|
31
|
-
message: () => this.failed ? toMessage(this.message) : `${toMessage(message, this.subject)}, which we did not expect.`
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var match = (subject) => new Match(subject);
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
Match,
|
|
39
|
-
match
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=chunk-LN24S2PC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matchers/Match.ts"],"sourcesContent":["import { isDefined } from '../utils/Utils';\nimport { Message, toMessage } from '../utils/Types';\n\nexport class Match<S> {\n constructor(private readonly subject: S, private readonly failed = false, private readonly message: Message<S> = '') {}\n\n not(p: (s: S) => boolean, message: Message<S>): Match<S> {\n if (this.failed) {\n return this;\n }\n try {\n return new Match<S>(this.subject, !p(this.subject), toMessage(message, this.subject));\n } catch (e: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return new Match<S>(this.subject, true, e.message);\n }\n }\n\n undefined(p: (s: S) => any, message: Message<S>): Match<S> {\n return this.not(() => isDefined(p(this.subject)), message);\n }\n\n else(message: Message<S>): jest.CustomMatcherResult {\n return {\n pass: !this.failed,\n message: () => (this.failed ? toMessage(this.message) : `${toMessage(message, this.subject)}, which we did not expect.`),\n };\n }\n}\n\nexport const match = <S>(subject: S): Match<S> => new Match<S>(subject);\n"],"mappings":";;;;;;;;AAGO,IAAM,QAAN,MAAM,OAAS;AAAA,EACpB,YAA6B,SAA6B,SAAS,OAAwB,UAAsB,IAAI;AAAxF;AAA6B;AAAiC;AAAA,EAA2B;AAAA,EAEtH,IAAI,GAAsB,SAA+B;AACvD,QAAI,KAAK,QAAQ;AACf,aAAO;AAAA,IACT;AACA,QAAI;AACF,aAAO,IAAI,OAAS,KAAK,SAAS,CAAC,EAAE,KAAK,OAAO,GAAG,UAAU,SAAS,KAAK,OAAO,CAAC;AAAA,IACtF,SAAS,GAAQ;AAEf,aAAO,IAAI,OAAS,KAAK,SAAS,MAAM,EAAE,OAAO;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,UAAU,GAAkB,SAA+B;AACzD,WAAO,KAAK,IAAI,MAAM,UAAU,EAAE,KAAK,OAAO,CAAC,GAAG,OAAO;AAAA,EAC3D;AAAA,EAEA,KAAK,SAA+C;AAClD,WAAO;AAAA,MACL,MAAM,CAAC,KAAK;AAAA,MACZ,SAAS,MAAO,KAAK,SAAS,UAAU,KAAK,OAAO,IAAI,GAAG,UAAU,SAAS,KAAK,OAAO,CAAC;AAAA,IAC7F;AAAA,EACF;AACF;AAEO,IAAM,QAAQ,CAAI,YAAyB,IAAI,MAAS,OAAO;","names":[]}
|
package/dist/chunk-MBQSBGEE.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-MBQSBGEE.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-O475TEG2.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// src/utils/Utils.ts
|
|
2
|
-
var isDefined = (o) => o !== void 0 && o !== null;
|
|
3
|
-
var isNumber = (o) => isDefined(o) && typeof o === "number" && !Number.isNaN(o);
|
|
4
|
-
var isFunction = (o) => isDefined(o) && typeof o === "function";
|
|
5
|
-
var isA = (t, ...properties) => isDefined(t) && properties.every((p) => isDefined(t[p]));
|
|
6
|
-
var isAn = isA;
|
|
7
|
-
var isArray = (o) => isDefined(o) && o instanceof Array;
|
|
8
|
-
var isObject = (o) => o != null && (typeof o === "object" || typeof o === "function") && !isArray(o);
|
|
9
|
-
var asJson = (a) => a?.toJSON ? a.toJSON() : isObject(a) ? a : void 0;
|
|
10
|
-
var asString = (a) => a?.toString();
|
|
11
|
-
var asNumber = (num, alt) => {
|
|
12
|
-
const n = parseInt(asString(num));
|
|
13
|
-
return isNumber(n) ? n : isFunction(alt) ? alt() : isNumber(alt) ? alt : NaN;
|
|
14
|
-
};
|
|
15
|
-
var toArray = (...items) => items.length > 1 ? items : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
isDefined,
|
|
19
|
-
isNumber,
|
|
20
|
-
isFunction,
|
|
21
|
-
isA,
|
|
22
|
-
isAn,
|
|
23
|
-
isArray,
|
|
24
|
-
isObject,
|
|
25
|
-
asJson,
|
|
26
|
-
asString,
|
|
27
|
-
asNumber,
|
|
28
|
-
toArray
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=chunk-O475TEG2.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/Utils.ts"],"sourcesContent":["import { ArrayLike } from './Types';\n\nexport const isDefined = <T = unknown>(o?: T): boolean => o !== undefined && o !== null;\n\nexport const isNumber = (o?: unknown): o is number => isDefined(o) && typeof o === 'number' && !Number.isNaN(o);\nexport const isFunction = (o?: unknown): o is (...params: unknown[]) => unknown => isDefined(o) && typeof o === 'function';\n\nexport const isA = <T>(t?: unknown, ...properties: (keyof T)[]): t is T => isDefined(t) && properties.every(p => isDefined((t as T)[p]));\nexport const isAn = isA;\n\nexport const isArray = <T = any>(o?: unknown): o is Array<T> => isDefined(o) && o instanceof Array;\nexport const isObject = (o?: unknown): o is Record<string, unknown> => o != null && (typeof o === 'object' || typeof o === 'function') && !isArray(o);\n\nexport const asJson = (a?: unknown): any => ((a as any)?.toJSON ? (a as any).toJSON() : isObject(a) ? a : undefined);\nexport const asString = (a?: unknown): string => (a as any)?.toString();\n\nexport const asNumber = (num: unknown, alt?: number | (() => number)): number => {\n const n = parseInt(asString(num));\n return isNumber(n) ? n : isFunction(alt) ? alt() : isNumber(alt) ? alt : NaN;\n};\n\nexport const toArray = <T>(...items: ArrayLike<T>): T[] =>\n items.length > 1 ? (items as T[]) : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];\n"],"mappings":";AAEO,IAAM,YAAY,CAAc,MAAmB,MAAM,UAAa,MAAM;AAE5E,IAAM,WAAW,CAAC,MAA6B,UAAU,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,OAAO,MAAM,CAAC;AACvG,IAAM,aAAa,CAAC,MAAwD,UAAU,CAAC,KAAK,OAAO,MAAM;AAEzG,IAAM,MAAM,CAAI,MAAgB,eAAoC,UAAU,CAAC,KAAK,WAAW,MAAM,OAAK,UAAW,EAAQ,CAAC,CAAC,CAAC;AAChI,IAAM,OAAO;AAEb,IAAM,UAAU,CAAU,MAA+B,UAAU,CAAC,KAAK,aAAa;AACtF,IAAM,WAAW,CAAC,MAA8C,KAAK,SAAS,OAAO,MAAM,YAAY,OAAO,MAAM,eAAe,CAAC,QAAQ,CAAC;AAE7I,IAAM,SAAS,CAAC,MAAuB,GAAW,SAAU,EAAU,OAAO,IAAI,SAAS,CAAC,IAAI,IAAI;AACnG,IAAM,WAAW,CAAC,MAAyB,GAAW,SAAS;AAE/D,IAAM,WAAW,CAAC,KAAc,QAA0C;AAC/E,QAAM,IAAI,SAAS,SAAS,GAAG,CAAC;AAChC,SAAO,SAAS,CAAC,IAAI,IAAI,WAAW,GAAG,IAAI,IAAI,IAAI,SAAS,GAAG,IAAI,MAAM;AAC3E;AAEO,IAAM,UAAU,IAAO,UAC5B,MAAM,SAAS,IAAK,QAAgB,QAAQ,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,UAAU,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;","names":[]}
|
package/dist/chunk-PPXFT3SX.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
match
|
|
3
|
-
} from "./chunk-LN24S2PC.mjs";
|
|
4
|
-
|
|
5
|
-
// src/matchers/toBeArrayOf.ts
|
|
6
|
-
var toBeArrayOf = (items, ctor) => match(items).undefined((it) => it, "Subject is undefined.").not((it) => it instanceof Array, "Subject is not an array.").not((it) => it.every((i) => i instanceof ctor), `Not all elements are of type '${ctor.name}'.`).else(`All elements in array are of type '${ctor.name}'`);
|
|
7
|
-
expect.extend({
|
|
8
|
-
toBeArrayOf
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
toBeArrayOf
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=chunk-PPXFT3SX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matchers/toBeArrayOf.ts"],"sourcesContent":["import { Constructor as Ctor } from '../utils/Types';\nimport { match } from './Match';\n\nexport const toBeArrayOf = <T>(items: unknown, ctor: Ctor<T>): jest.CustomMatcherResult =>\n match<unknown>(items)\n .undefined(it => it, 'Subject is undefined.')\n .not(it => it instanceof Array, 'Subject is not an array.')\n .not(it => (it as []).every((i: any) => i instanceof ctor), `Not all elements are of type '${ctor.name}'.`)\n .else(`All elements in array are of type '${ctor.name}'`);\n\nexpect.extend({\n toBeArrayOf,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeArrayOf<Z>(ctor: Ctor<Z>): R;\n }\n }\n}\n"],"mappings":";;;;;AAGO,IAAM,cAAc,CAAI,OAAgB,SAC7C,MAAe,KAAK,EACjB,UAAU,QAAM,IAAI,uBAAuB,EAC3C,IAAI,QAAM,cAAc,OAAO,0BAA0B,EACzD,IAAI,QAAO,GAAU,MAAM,CAAC,MAAW,aAAa,IAAI,GAAG,iCAAiC,KAAK,IAAI,IAAI,EACzG,KAAK,sCAAsC,KAAK,IAAI,GAAG;AAE5D,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
package/dist/chunk-QE3TR4BY.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
asString
|
|
3
|
-
} from "./chunk-O475TEG2.mjs";
|
|
4
|
-
|
|
5
|
-
// src/utils/Eq.ts
|
|
6
|
-
import { equals, iterableEquality, subsetEquality } from "@jest/expect-utils";
|
|
7
|
-
var eq = {
|
|
8
|
-
exact: (a, b) => equals(a, b, []),
|
|
9
|
-
subset: (a, b) => equals(a, b, [iterableEquality, subsetEquality]),
|
|
10
|
-
string: (a, b) => asString(a) === asString(b)
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
eq
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-QE3TR4BY.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/Eq.ts"],"sourcesContent":["import { asString } from './Utils';\nimport { equals, iterableEquality, subsetEquality } from '@jest/expect-utils';\n\nexport const eq = {\n exact: (a?: unknown, b?: unknown): boolean => equals(a, b, []),\n subset: (a?: unknown, b?: unknown): boolean => equals(a, b, [iterableEquality, subsetEquality]),\n string: (a?: unknown, b?: unknown): boolean => asString(a) === asString(b),\n};\n"],"mappings":";;;;;AACA,SAAS,QAAQ,kBAAkB,sBAAsB;AAElD,IAAM,KAAK;AAAA,EAChB,OAAO,CAAC,GAAa,MAAyB,OAAO,GAAG,GAAG,CAAC,CAAC;AAAA,EAC7D,QAAQ,CAAC,GAAa,MAAyB,OAAO,GAAG,GAAG,CAAC,kBAAkB,cAAc,CAAC;AAAA,EAC9F,QAAQ,CAAC,GAAa,MAAyB,SAAS,CAAC,MAAM,SAAS,CAAC;AAC3E;","names":[]}
|
package/dist/chunk-QWLALNJL.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
match
|
|
3
|
-
} from "./chunk-LN24S2PC.mjs";
|
|
4
|
-
|
|
5
|
-
// src/matchers/ResultMatchers.ts
|
|
6
|
-
var notDefined = "Results is not defined.";
|
|
7
|
-
var doesNotFail = "Results does not fail.";
|
|
8
|
-
var hasMessage = (res, message) => res.results.some((r) => r.message === message);
|
|
9
|
-
var messages = (res) => "'" + res?.results.map((r) => r.message).join("', '") + "'";
|
|
10
|
-
var toResultWith = (results, message) => match(results).undefined((r) => r, notDefined).not(
|
|
11
|
-
(r) => hasMessage(r, message),
|
|
12
|
-
(r) => `Results does not have message '${message}', but it has messages ${messages(r)} instead.`
|
|
13
|
-
).else(`Succeeds with message ${message}`);
|
|
14
|
-
var toFail = (results) => match(results).undefined((r) => r, notDefined).not((r) => !r.isValid, doesNotFail).else("Results does not fail");
|
|
15
|
-
var toFailWith = (results, message) => match(results).undefined((r) => r, notDefined).not((r) => !r.isValid, doesNotFail).not(
|
|
16
|
-
(r) => hasMessage(r, message),
|
|
17
|
-
(r) => `Fails, but results does not have message '${message}', but it has messages ${messages(r)} instead.`
|
|
18
|
-
).else(`Fails with message '${message}'`);
|
|
19
|
-
expect.extend({
|
|
20
|
-
toResultWith,
|
|
21
|
-
toFail,
|
|
22
|
-
toFailWith
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
toResultWith,
|
|
27
|
-
toFail,
|
|
28
|
-
toFailWith
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=chunk-QWLALNJL.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matchers/ResultMatchers.ts"],"sourcesContent":["import { match } from './Match';\nimport { Results } from '../utils/Types';\n\n// Tests for handling Results.\n\nconst notDefined = 'Results is not defined.';\nconst doesNotFail = 'Results does not fail.';\n\nconst hasMessage = (res: Results, message: string) => res.results.some((r: any) => r.message === message);\n\nconst messages = (res: Results): string => \"'\" + res?.results.map(r => r.message).join(\"', '\") + \"'\";\n\nexport const toResultWith = (results: Results, message: string): jest.CustomMatcherResult =>\n match(results)\n .undefined(r => r, notDefined)\n .not(\n r => hasMessage(r, message),\n r => `Results does not have message '${message}', but it has messages ${messages(r)} instead.`\n )\n .else(`Succeeds with message ${message}`);\n\nexport const toFail = (results: Results): jest.CustomMatcherResult =>\n match(results)\n .undefined(r => r, notDefined)\n .not(r => !r.isValid, doesNotFail)\n .else('Results does not fail');\n\nexport const toFailWith = (results: Results, message: string): jest.CustomMatcherResult =>\n match(results)\n .undefined(r => r, notDefined)\n .not(r => !r.isValid, doesNotFail)\n .not(\n r => hasMessage(r, message),\n r => `Fails, but results does not have message '${message}', but it has messages ${messages(r)} instead.`\n )\n .else(`Fails with message '${message}'`);\n\nexpect.extend({\n toResultWith,\n toFail: toFail,\n toFailWith: toFailWith,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toResultWith(message: string): R;\n toFail(): R;\n toFailWith(message: string): R;\n }\n }\n}\n"],"mappings":";;;;;AAKA,IAAM,aAAa;AACnB,IAAM,cAAc;AAEpB,IAAM,aAAa,CAAC,KAAc,YAAoB,IAAI,QAAQ,KAAK,CAAC,MAAW,EAAE,YAAY,OAAO;AAExG,IAAM,WAAW,CAAC,QAAyB,MAAM,KAAK,QAAQ,IAAI,OAAK,EAAE,OAAO,EAAE,KAAK,MAAM,IAAI;AAE1F,IAAM,eAAe,CAAC,SAAkB,YAC7C,MAAM,OAAO,EACV,UAAU,OAAK,GAAG,UAAU,EAC5B;AAAA,EACC,OAAK,WAAW,GAAG,OAAO;AAAA,EAC1B,OAAK,kCAAkC,OAAO,0BAA0B,SAAS,CAAC,CAAC;AACrF,EACC,KAAK,yBAAyB,OAAO,EAAE;AAErC,IAAM,SAAS,CAAC,YACrB,MAAM,OAAO,EACV,UAAU,OAAK,GAAG,UAAU,EAC5B,IAAI,OAAK,CAAC,EAAE,SAAS,WAAW,EAChC,KAAK,uBAAuB;AAE1B,IAAM,aAAa,CAAC,SAAkB,YAC3C,MAAM,OAAO,EACV,UAAU,OAAK,GAAG,UAAU,EAC5B,IAAI,OAAK,CAAC,EAAE,SAAS,WAAW,EAChC;AAAA,EACC,OAAK,WAAW,GAAG,OAAO;AAAA,EAC1B,OAAK,6CAA6C,OAAO,0BAA0B,SAAS,CAAC,CAAC;AAChG,EACC,KAAK,uBAAuB,OAAO,GAAG;AAE3C,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":[]}
|
package/dist/chunk-RPYWAKYZ.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
match
|
|
3
|
-
} from "./chunk-LN24S2PC.mjs";
|
|
4
|
-
import {
|
|
5
|
-
toMessage
|
|
6
|
-
} from "./chunk-6EKWTLNQ.mjs";
|
|
7
|
-
|
|
8
|
-
// src/matchers/toPassMatcher.ts
|
|
9
|
-
var Passes = {
|
|
10
|
-
Yes: "Match passes, instead of fails.",
|
|
11
|
-
No: (reason) => `Match doesn't pass, because '${reason}'`
|
|
12
|
-
};
|
|
13
|
-
var PassesWith = {
|
|
14
|
-
Yes: "Match passes with correct message.",
|
|
15
|
-
No: (message, instead) => `Match does pass, however not with message '${message}', but with message '${instead}' instead.`
|
|
16
|
-
};
|
|
17
|
-
var toPassMatcher = (result) => match(result).not(
|
|
18
|
-
(c) => c.pass,
|
|
19
|
-
(c) => Passes.No(c.message())
|
|
20
|
-
).else(Passes.Yes);
|
|
21
|
-
var toPassMatcherWith = (result, message) => match(result).not(
|
|
22
|
-
(c) => c.pass,
|
|
23
|
-
(c) => Passes.No(c.message())
|
|
24
|
-
).not(
|
|
25
|
-
(c) => c.message().includes(toMessage(message)),
|
|
26
|
-
(c) => PassesWith.No(toMessage(message), c.message())
|
|
27
|
-
).else(PassesWith.Yes);
|
|
28
|
-
expect.extend({
|
|
29
|
-
toPassMatcher,
|
|
30
|
-
toPassMatcherWith
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
Passes,
|
|
35
|
-
PassesWith,
|
|
36
|
-
toPassMatcher,
|
|
37
|
-
toPassMatcherWith
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=chunk-RPYWAKYZ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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/chunk-SGV4XPW3.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
eq
|
|
3
|
-
} from "./chunk-QE3TR4BY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
match
|
|
6
|
-
} from "./chunk-LN24S2PC.mjs";
|
|
7
|
-
import {
|
|
8
|
-
asJson
|
|
9
|
-
} from "./chunk-O475TEG2.mjs";
|
|
10
|
-
|
|
11
|
-
// src/matchers/toMatchJson.ts
|
|
12
|
-
var MatchesJson = {
|
|
13
|
-
SubjectUndefined: "Subject is undefined.",
|
|
14
|
-
SubsetUndefined: "Subset to match with is undefined.",
|
|
15
|
-
DoesNotMatch: "Subset does not match subject.",
|
|
16
|
-
Yes: "Subset matches subject"
|
|
17
|
-
};
|
|
18
|
-
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);
|
|
19
|
-
expect.extend({
|
|
20
|
-
toMatchJson
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
MatchesJson,
|
|
25
|
-
toMatchJson
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=chunk-SGV4XPW3.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
package/dist/chunk-SJR3TRWF.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
asNumber,
|
|
3
|
-
isDefined
|
|
4
|
-
} from "./chunk-O475TEG2.mjs";
|
|
5
|
-
|
|
6
|
-
// src/utils/Req.ts
|
|
7
|
-
var Req = class {
|
|
8
|
-
constructor(state = {}) {
|
|
9
|
-
this.state = state;
|
|
10
|
-
this.skip = isDefined(this.query?.skip) ? asNumber(this.query?.skip) : void 0;
|
|
11
|
-
this.take = isDefined(this.query?.take) ? asNumber(this.query?.take) : void 0;
|
|
12
|
-
}
|
|
13
|
-
skip;
|
|
14
|
-
take;
|
|
15
|
-
get id() {
|
|
16
|
-
return this.state.id ?? this.path.id;
|
|
17
|
-
}
|
|
18
|
-
get q() {
|
|
19
|
-
return this.state.q ?? this.query.q;
|
|
20
|
-
}
|
|
21
|
-
get path() {
|
|
22
|
-
return this.state?.path ?? {};
|
|
23
|
-
}
|
|
24
|
-
get query() {
|
|
25
|
-
return this.state?.query ?? {};
|
|
26
|
-
}
|
|
27
|
-
get body() {
|
|
28
|
-
return this.state.body;
|
|
29
|
-
}
|
|
30
|
-
get headers() {
|
|
31
|
-
return this.state.headers;
|
|
32
|
-
}
|
|
33
|
-
get = (key) => this?.state[key.toString()] ?? this.path[key.toString()] ?? this.query[key.toString()];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
Req
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=chunk-SJR3TRWF.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/Req.ts"],"sourcesContent":["import { asNumber, isDefined } from './Utils';\nimport { Id, Json, JsonValue, OneOrMore, Text } from './Types';\n\nexport class Req<B = unknown> {\n readonly skip: number | undefined;\n readonly take: number | undefined;\n\n constructor(readonly state: any = {}) {\n this.skip = isDefined(this.query?.skip) ? asNumber(this.query?.skip) : undefined;\n this.take = isDefined(this.query?.take) ? asNumber(this.query?.take) : undefined;\n }\n\n get id(): Id {\n return this.state.id ?? this.path.id;\n }\n\n get q(): JsonValue {\n return this.state.q ?? this.query.q;\n }\n\n get path(): Json {\n return this.state?.path ?? {};\n }\n\n get query(): Json {\n return this.state?.query ?? {};\n }\n\n get body(): B {\n return this.state.body;\n }\n\n get headers(): Record<string, OneOrMore<string>> {\n return this.state.headers;\n }\n\n get = (key: Text): any => this?.state[key.toString()] ?? this.path[key.toString()] ?? this.query[key.toString()];\n}\n"],"mappings":";;;;;;AAGO,IAAM,MAAN,MAAuB;AAAA,EAI5B,YAAqB,QAAa,CAAC,GAAG;AAAjB;AACnB,SAAK,OAAO,UAAU,KAAK,OAAO,IAAI,IAAI,SAAS,KAAK,OAAO,IAAI,IAAI;AACvE,SAAK,OAAO,UAAU,KAAK,OAAO,IAAI,IAAI,SAAS,KAAK,OAAO,IAAI,IAAI;AAAA,EACzE;AAAA,EANS;AAAA,EACA;AAAA,EAOT,IAAI,KAAS;AACX,WAAO,KAAK,MAAM,MAAM,KAAK,KAAK;AAAA,EACpC;AAAA,EAEA,IAAI,IAAe;AACjB,WAAO,KAAK,MAAM,KAAK,KAAK,MAAM;AAAA,EACpC;AAAA,EAEA,IAAI,OAAa;AACf,WAAO,KAAK,OAAO,QAAQ,CAAC;AAAA,EAC9B;AAAA,EAEA,IAAI,QAAc;AAChB,WAAO,KAAK,OAAO,SAAS,CAAC;AAAA,EAC/B;AAAA,EAEA,IAAI,OAAU;AACZ,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAEA,IAAI,UAA6C;AAC/C,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAEA,MAAM,CAAC,QAAmB,MAAM,MAAM,IAAI,SAAS,CAAC,KAAK,KAAK,KAAK,IAAI,SAAS,CAAC,KAAK,KAAK,MAAM,IAAI,SAAS,CAAC;AACjH;","names":[]}
|
package/dist/chunk-TUE23FNE.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
match
|
|
3
|
-
} from "./chunk-LN24S2PC.mjs";
|
|
4
|
-
|
|
5
|
-
// src/matchers/toBeQueriedWith.ts
|
|
6
|
-
var toBeQueriedWith = (query, expected) => match(query?.mock?.calls).undefined((c) => c, "Query is unknown.").not((c) => c.length === 1, "Query did not execute.").not(
|
|
7
|
-
(c) => c[0][0].toString() === expected?.toString(),
|
|
8
|
-
(c) => `We expected query '${expected}', but we received query '${c[0][0]}' instead.`
|
|
9
|
-
).else(`Received query does match '${expected}'`);
|
|
10
|
-
expect.extend({
|
|
11
|
-
toBeQueriedWith
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
toBeQueriedWith
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=chunk-TUE23FNE.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/matchers/toBeQueriedWith.ts"],"sourcesContent":["import { match } from './Match';\nimport { Query } from '../utils/Types';\n\nexport const toBeQueriedWith = (query: jest.Mock, expected: Query): jest.CustomMatcherResult =>\n match<any[]>(query?.mock?.calls)\n .undefined(c => c, 'Query is unknown.')\n .not(c => c.length === 1, 'Query did not execute.')\n .not(\n c => c[0][0].toString() === expected?.toString(),\n c => `We expected query '${expected}', but we received query '${c[0][0]}' instead.`\n )\n .else(`Received query does match '${expected}'`);\n\nexpect.extend({\n toBeQueriedWith: toBeQueriedWith,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeQueriedWith(expected: Query): R;\n }\n }\n}\n"],"mappings":";;;;;AAGO,IAAM,kBAAkB,CAAC,OAAkB,aAChD,MAAa,OAAO,MAAM,KAAK,EAC5B,UAAU,OAAK,GAAG,mBAAmB,EACrC,IAAI,OAAK,EAAE,WAAW,GAAG,wBAAwB,EACjD;AAAA,EACC,OAAK,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,MAAM,UAAU,SAAS;AAAA,EAC/C,OAAK,sBAAsB,QAAQ,6BAA6B,EAAE,CAAC,EAAE,CAAC,CAAC;AACzE,EACC,KAAK,8BAA8B,QAAQ,GAAG;AAEnD,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
|
package/dist/chunk-UFDXFCRK.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
checkDefined
|
|
3
|
-
} from "./chunk-Z4XAP66Q.mjs";
|
|
4
|
-
|
|
5
|
-
// src/matchers/toMatchArray.ts
|
|
6
|
-
function toMatchArray(received, expected) {
|
|
7
|
-
return checkDefined(this, received, expected).not(
|
|
8
|
-
([r, e]) => r.length === e.length,
|
|
9
|
-
([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`
|
|
10
|
-
).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();
|
|
11
|
-
}
|
|
12
|
-
expect.extend({
|
|
13
|
-
toMatchArray
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
toMatchArray
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=chunk-UFDXFCRK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|