@thisisagile/easy-test 15.26.1 → 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/Types.ts"],"sourcesContent":["import { asString, isFunction } from './Utils';\n\nexport type OneOrMore<T> = T | Array<T>;\n\nexport type ArrayLike<T> = OneOrMore<T>[];\n\nexport type Constructor<T> = { new (...args: any[]): T };\n\nexport type Message<P> = Text | ((...params: P[]) => Text);\n\nexport const toMessage = <P>(g: Message<P>, ...params: P[]): string => asString(isFunction(g) ? g(...params) : g);\n\nexport type Validatable = { isValid: boolean };\n\nexport type Result = { domain?: string; location?: string; message: string };\n\nexport type Results = Validatable & { results: Result[] };\n\nexport type Uri = Text;\n\nexport type Id = string | number;\n\nexport type JsonValue = string | number | boolean | null | Json | JsonValue[];\n\nexport type Json = { [key: string]: JsonValue };\n\nexport type Exception = { id: Id; reason?: string };\n\nexport type Text = { toString: () => string };\n\nexport type Query = Text;\n\nexport type UseCase = { app: { id: Text }; id: Text };\n\nexport type Tester = { url: string };\n\nexport type CreateMutable<T> = { -readonly [P in keyof T]: T[P] };\n"],"mappings":";;;;;;AAUO,IAAM,YAAY,CAAI,MAAkB,WAAwB,SAAS,WAAW,CAAC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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-KAVJOG5T.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 {\n readonly skip: number | undefined;\n readonly take: number | undefined;\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(): unknown {\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,MAAU;AAAA,EAGf,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,EALS;AAAA,EACA;AAAA,EAMT,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,OAAgB;AAClB,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":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isDefined
|
|
3
|
+
} from "./chunk-O475TEG2.mjs";
|
|
4
|
+
|
|
5
|
+
// src/matchers/Check.ts
|
|
6
|
+
var Check = class _Check {
|
|
7
|
+
constructor(ctx, received, expected, failed = false, message = "") {
|
|
8
|
+
this.ctx = ctx;
|
|
9
|
+
this.received = received;
|
|
10
|
+
this.expected = expected;
|
|
11
|
+
this.failed = failed;
|
|
12
|
+
this.message = message;
|
|
13
|
+
}
|
|
14
|
+
print(message) {
|
|
15
|
+
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) ?? "");
|
|
16
|
+
}
|
|
17
|
+
not(p, message) {
|
|
18
|
+
if (this.failed) {
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
return new _Check(this.ctx, this.received, this.expected, !p([this.received, this.expected]), this.print(message));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return new _Check(this.ctx, this.received, this.expected, true, e.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
undefined(p, message) {
|
|
28
|
+
return this.not(() => isDefined(p([this.received, this.expected])), this.print(message));
|
|
29
|
+
}
|
|
30
|
+
else(message = "Expected {r} not to match with {e}, but it did.") {
|
|
31
|
+
return {
|
|
32
|
+
pass: !this.failed,
|
|
33
|
+
message: () => this.failed ? this.message : this.print(message)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var check = (ctx, received, expected) => new Check(ctx, received, expected);
|
|
38
|
+
var checkDefined = (ctx, received, expected) => new Check(ctx, received, expected).undefined(([r]) => r, "Received array is undefined.").undefined(([, e]) => e, "Expected array is undefined.");
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
check,
|
|
42
|
+
checkDefined
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=chunk-Z4XAP66Q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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":";;;;;AAIA,IAAM,QAAN,MAAM,OAAS;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,OAAS,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,OAAS,KAAK,KAAK,KAAK,UAAU,KAAK,UAAU,MAAM,EAAE,OAAO;AAAA,IAC7E;AAAA,EACF;AAAA,EAEA,UAAU,GAAoB,SAAiC;AAC7D,WAAO,KAAK,IAAI,MAAM,UAAU,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,IAAM,QAAQ,CAAI,KAA0B,UAAa,aAA2B,IAAI,MAAS,KAAK,UAAU,QAAa;AAE7H,IAAM,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":[]}
|