@thisisagile/easy-test 15.8.6 → 15.8.8
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 +2 -379
- package/dist/index.js +25 -3
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -0
- package/dist/matchers/Check.d.ts +17 -0
- package/dist/matchers/Check.js +64 -0
- package/dist/matchers/Check.js.map +1 -0
- package/dist/matchers/Check.mjs +39 -0
- package/dist/matchers/Check.mjs.map +1 -0
- package/dist/matchers/HttpMatchers.d.ts +31 -0
- package/dist/matchers/HttpMatchers.js +89 -0
- package/dist/matchers/HttpMatchers.js.map +1 -0
- package/dist/matchers/HttpMatchers.mjs +54 -0
- package/dist/matchers/HttpMatchers.mjs.map +1 -0
- package/dist/matchers/Match.d.ts +12 -0
- package/dist/matchers/Match.js +59 -0
- package/dist/matchers/Match.js.map +1 -0
- package/dist/matchers/Match.mjs +34 -0
- package/dist/matchers/Match.mjs.map +1 -0
- package/dist/matchers/ResultMatchers.d.ts +13 -0
- package/dist/matchers/ResultMatchers.js +51 -0
- package/dist/matchers/ResultMatchers.js.map +1 -0
- package/dist/matchers/ResultMatchers.mjs +25 -0
- package/dist/matchers/ResultMatchers.mjs.map +1 -0
- package/dist/matchers/index.d.ts +19 -0
- package/dist/matchers/index.js +59 -0
- package/dist/matchers/index.js.map +1 -0
- package/dist/matchers/index.mjs +20 -0
- package/dist/matchers/index.mjs.map +1 -0
- package/dist/matchers/toBeArrayOf.d.ts +9 -0
- package/dist/matchers/toBeArrayOf.js +33 -0
- package/dist/matchers/toBeArrayOf.js.map +1 -0
- package/dist/matchers/toBeArrayOf.mjs +9 -0
- package/dist/matchers/toBeArrayOf.mjs.map +1 -0
- package/dist/matchers/toBeArrayOfWithLength.d.ts +9 -0
- package/dist/matchers/toBeArrayOfWithLength.js +36 -0
- package/dist/matchers/toBeArrayOfWithLength.js.map +1 -0
- package/dist/matchers/toBeArrayOfWithLength.mjs +12 -0
- package/dist/matchers/toBeArrayOfWithLength.mjs.map +1 -0
- package/dist/matchers/toBeAt.d.ts +9 -0
- package/dist/matchers/toBeAt.js +44 -0
- package/dist/matchers/toBeAt.js.map +1 -0
- package/dist/matchers/toBeAt.mjs +20 -0
- package/dist/matchers/toBeAt.mjs.map +1 -0
- package/dist/matchers/toBeExactlyAt.d.ts +9 -0
- package/dist/matchers/toBeExactlyAt.js +43 -0
- package/dist/matchers/toBeExactlyAt.js.map +1 -0
- package/dist/matchers/toBeExactlyAt.mjs +19 -0
- package/dist/matchers/toBeExactlyAt.mjs.map +1 -0
- package/dist/matchers/toBeQueriedWith.d.ts +9 -0
- package/dist/matchers/toBeQueriedWith.js +36 -0
- package/dist/matchers/toBeQueriedWith.js.map +1 -0
- package/dist/matchers/toBeQueriedWith.mjs +12 -0
- package/dist/matchers/toBeQueriedWith.mjs.map +1 -0
- package/dist/matchers/toBeRoutedTo.d.ts +9 -0
- package/dist/matchers/toBeRoutedTo.js +37 -0
- package/dist/matchers/toBeRoutedTo.js.map +1 -0
- package/dist/matchers/toBeRoutedTo.mjs +13 -0
- package/dist/matchers/toBeRoutedTo.mjs.map +1 -0
- package/dist/matchers/toBeValid.d.ts +8 -0
- package/dist/matchers/toBeValid.js +34 -0
- package/dist/matchers/toBeValid.js.map +1 -0
- package/dist/matchers/toBeValid.mjs +10 -0
- package/dist/matchers/toBeValid.mjs.map +1 -0
- package/dist/matchers/toFailMatcher.d.ts +19 -0
- package/dist/matchers/toFailMatcher.js +59 -0
- package/dist/matchers/toFailMatcher.js.map +1 -0
- package/dist/matchers/toFailMatcher.mjs +32 -0
- package/dist/matchers/toFailMatcher.mjs.map +1 -0
- package/dist/matchers/toMatchArray.d.ts +9 -0
- package/dist/matchers/toMatchArray.js +35 -0
- package/dist/matchers/toMatchArray.js.map +1 -0
- package/dist/matchers/toMatchArray.mjs +11 -0
- package/dist/matchers/toMatchArray.mjs.map +1 -0
- package/dist/matchers/toMatchExactJson.d.ts +14 -0
- package/dist/matchers/toMatchExactJson.js +42 -0
- package/dist/matchers/toMatchExactJson.js.map +1 -0
- package/dist/matchers/toMatchExactJson.mjs +17 -0
- package/dist/matchers/toMatchExactJson.mjs.map +1 -0
- package/dist/matchers/toMatchException.d.ts +9 -0
- package/dist/matchers/toMatchException.js +43 -0
- package/dist/matchers/toMatchException.js.map +1 -0
- package/dist/matchers/toMatchException.mjs +19 -0
- package/dist/matchers/toMatchException.mjs.map +1 -0
- package/dist/matchers/toMatchJson.d.ts +14 -0
- package/dist/matchers/toMatchJson.js +43 -0
- package/dist/matchers/toMatchJson.js.map +1 -0
- package/dist/matchers/toMatchJson.mjs +18 -0
- package/dist/matchers/toMatchJson.mjs.map +1 -0
- package/dist/matchers/toMatchRoute.d.ts +9 -0
- package/dist/matchers/toMatchRoute.js +37 -0
- package/dist/matchers/toMatchRoute.js.map +1 -0
- package/dist/matchers/toMatchRoute.mjs +13 -0
- package/dist/matchers/toMatchRoute.mjs.map +1 -0
- package/dist/matchers/toMatchText.d.ts +8 -0
- package/dist/matchers/toMatchText.js +37 -0
- package/dist/matchers/toMatchText.js.map +1 -0
- package/dist/matchers/toMatchText.mjs +13 -0
- package/dist/matchers/toMatchText.mjs.map +1 -0
- package/dist/matchers/toPassMatcher.d.ts +19 -0
- package/dist/matchers/toPassMatcher.js +59 -0
- package/dist/matchers/toPassMatcher.js.map +1 -0
- package/dist/matchers/toPassMatcher.mjs +32 -0
- package/dist/matchers/toPassMatcher.mjs.map +1 -0
- package/dist/mock/Fits.d.ts +24 -0
- package/dist/mock/Fits.js +71 -0
- package/dist/mock/Fits.js.map +1 -0
- package/dist/mock/Fits.mjs +44 -0
- package/dist/mock/Fits.mjs.map +1 -0
- package/dist/mock/Mocks.d.ts +39 -0
- package/dist/mock/Mocks.js +98 -0
- package/dist/mock/Mocks.js.map +1 -0
- package/dist/mock/Mocks.mjs +73 -0
- package/dist/mock/Mocks.mjs.map +1 -0
- package/dist/mock/index.d.ts +2 -0
- package/dist/mock/index.js +25 -0
- package/dist/mock/index.js.map +1 -0
- package/dist/mock/index.mjs +3 -0
- package/dist/mock/index.mjs.map +1 -0
- package/dist/utils/Eq.d.ts +5 -0
- package/dist/utils/Eq.js +35 -0
- package/dist/utils/Eq.js.map +1 -0
- package/dist/utils/Eq.mjs +11 -0
- package/dist/utils/Eq.mjs.map +1 -0
- package/dist/utils/Req.d.ts +14 -0
- package/dist/utils/Req.js +57 -0
- package/dist/utils/Req.js.map +1 -0
- package/dist/utils/Req.mjs +33 -0
- package/dist/utils/Req.mjs.map +1 -0
- package/dist/utils/Response.d.ts +25 -0
- package/dist/utils/Response.js +17 -0
- package/dist/utils/Response.js.map +1 -0
- package/dist/utils/Response.mjs +1 -0
- package/dist/utils/Response.mjs.map +1 -0
- package/dist/utils/Types.d.ts +44 -0
- package/dist/utils/Types.js +30 -0
- package/dist/utils/Types.js.map +1 -0
- package/dist/utils/Types.mjs +6 -0
- package/dist/utils/Types.mjs.map +1 -0
- package/dist/utils/Utils.d.ts +12 -0
- package/dist/utils/Utils.js +62 -0
- package/dist/utils/Utils.js.map +1 -0
- package/dist/utils/Utils.mjs +28 -0
- package/dist/utils/Utils.mjs.map +1 -0
- package/package.json +2 -2
- package/src/utils/Req.ts +7 -10
- package/dist/index.d.mts +0 -379
|
@@ -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":"AAAA,SAAS,UAAU,kBAAkB;AAU9B,MAAM,YAAY,CAAI,MAAkB,WAAwB,SAAS,WAAW,CAAC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArrayLike } from './Types';
|
|
2
|
+
export declare const isDefined: <T = unknown>(o?: T | undefined) => boolean;
|
|
3
|
+
export declare const isNumber: (o?: unknown) => o is number;
|
|
4
|
+
export declare const isFunction: (o?: unknown) => o is (...params: unknown[]) => unknown;
|
|
5
|
+
export declare const isA: <T>(t?: unknown, ...properties: (keyof T)[]) => t is T;
|
|
6
|
+
export declare const isAn: <T>(t?: unknown, ...properties: (keyof T)[]) => t is T;
|
|
7
|
+
export declare const isArray: <T = any>(o?: unknown) => o is T[];
|
|
8
|
+
export declare const isObject: (o?: unknown) => o is Record<string, unknown>;
|
|
9
|
+
export declare const asJson: (a?: unknown) => any;
|
|
10
|
+
export declare const asString: (a?: unknown) => string;
|
|
11
|
+
export declare const asNumber: (num: unknown, alt?: number | (() => number)) => number;
|
|
12
|
+
export declare const toArray: <T>(...items: ArrayLike<T>) => T[];
|
|
@@ -0,0 +1,62 @@
|
|
|
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 Utils_exports = {};
|
|
20
|
+
__export(Utils_exports, {
|
|
21
|
+
asJson: () => asJson,
|
|
22
|
+
asNumber: () => asNumber,
|
|
23
|
+
asString: () => asString,
|
|
24
|
+
isA: () => isA,
|
|
25
|
+
isAn: () => isAn,
|
|
26
|
+
isArray: () => isArray,
|
|
27
|
+
isDefined: () => isDefined,
|
|
28
|
+
isFunction: () => isFunction,
|
|
29
|
+
isNumber: () => isNumber,
|
|
30
|
+
isObject: () => isObject,
|
|
31
|
+
toArray: () => toArray
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Utils_exports);
|
|
34
|
+
const isDefined = (o) => o !== void 0 && o !== null;
|
|
35
|
+
const isNumber = (o) => isDefined(o) && typeof o === "number" && !Number.isNaN(o);
|
|
36
|
+
const isFunction = (o) => isDefined(o) && typeof o === "function";
|
|
37
|
+
const isA = (t, ...properties) => isDefined(t) && properties.every((p) => isDefined(t[p]));
|
|
38
|
+
const isAn = isA;
|
|
39
|
+
const isArray = (o) => isDefined(o) && o instanceof Array;
|
|
40
|
+
const isObject = (o) => o != null && (typeof o === "object" || typeof o === "function") && !isArray(o);
|
|
41
|
+
const asJson = (a) => a?.toJSON ? a.toJSON() : isObject(a) ? a : void 0;
|
|
42
|
+
const asString = (a) => a?.toString();
|
|
43
|
+
const asNumber = (num, alt) => {
|
|
44
|
+
const n = parseInt(asString(num));
|
|
45
|
+
return isNumber(n) ? n : isFunction(alt) ? alt() : isNumber(alt) ? alt : NaN;
|
|
46
|
+
};
|
|
47
|
+
const toArray = (...items) => items.length > 1 ? items : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
asJson,
|
|
51
|
+
asNumber,
|
|
52
|
+
asString,
|
|
53
|
+
isA,
|
|
54
|
+
isAn,
|
|
55
|
+
isArray,
|
|
56
|
+
isDefined,
|
|
57
|
+
isFunction,
|
|
58
|
+
isNumber,
|
|
59
|
+
isObject,
|
|
60
|
+
toArray
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=Utils.js.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,YAAY,CAAc,MAAmB,MAAM,UAAa,MAAM;AAE5E,MAAM,WAAW,CAAC,MAA6B,UAAU,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,OAAO,MAAM,CAAC;AACvG,MAAM,aAAa,CAAC,MAAwD,UAAU,CAAC,KAAK,OAAO,MAAM;AAEzG,MAAM,MAAM,CAAI,MAAgB,eAAoC,UAAU,CAAC,KAAK,WAAW,MAAM,OAAK,UAAW,EAAQ,CAAC,CAAC,CAAC;AAChI,MAAM,OAAO;AAEb,MAAM,UAAU,CAAU,MAA+B,UAAU,CAAC,KAAK,aAAa;AACtF,MAAM,WAAW,CAAC,MAA8C,KAAK,SAAS,OAAO,MAAM,YAAY,OAAO,MAAM,eAAe,CAAC,QAAQ,CAAC;AAE7I,MAAM,SAAS,CAAC,MAAuB,GAAW,SAAU,EAAU,OAAO,IAAI,SAAS,CAAC,IAAI,IAAI;AACnG,MAAM,WAAW,CAAC,MAAyB,GAAW,SAAS;AAE/D,MAAM,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,MAAM,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,28 @@
|
|
|
1
|
+
const isDefined = (o) => o !== void 0 && o !== null;
|
|
2
|
+
const isNumber = (o) => isDefined(o) && typeof o === "number" && !Number.isNaN(o);
|
|
3
|
+
const isFunction = (o) => isDefined(o) && typeof o === "function";
|
|
4
|
+
const isA = (t, ...properties) => isDefined(t) && properties.every((p) => isDefined(t[p]));
|
|
5
|
+
const isAn = isA;
|
|
6
|
+
const isArray = (o) => isDefined(o) && o instanceof Array;
|
|
7
|
+
const isObject = (o) => o != null && (typeof o === "object" || typeof o === "function") && !isArray(o);
|
|
8
|
+
const asJson = (a) => a?.toJSON ? a.toJSON() : isObject(a) ? a : void 0;
|
|
9
|
+
const asString = (a) => a?.toString();
|
|
10
|
+
const asNumber = (num, alt) => {
|
|
11
|
+
const n = parseInt(asString(num));
|
|
12
|
+
return isNumber(n) ? n : isFunction(alt) ? alt() : isNumber(alt) ? alt : NaN;
|
|
13
|
+
};
|
|
14
|
+
const toArray = (...items) => items.length > 1 ? items : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];
|
|
15
|
+
export {
|
|
16
|
+
asJson,
|
|
17
|
+
asNumber,
|
|
18
|
+
asString,
|
|
19
|
+
isA,
|
|
20
|
+
isAn,
|
|
21
|
+
isArray,
|
|
22
|
+
isDefined,
|
|
23
|
+
isFunction,
|
|
24
|
+
isNumber,
|
|
25
|
+
isObject,
|
|
26
|
+
toArray
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=Utils.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,MAAM,YAAY,CAAc,MAAmB,MAAM,UAAa,MAAM;AAE5E,MAAM,WAAW,CAAC,MAA6B,UAAU,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,OAAO,MAAM,CAAC;AACvG,MAAM,aAAa,CAAC,MAAwD,UAAU,CAAC,KAAK,OAAO,MAAM;AAEzG,MAAM,MAAM,CAAI,MAAgB,eAAoC,UAAU,CAAC,KAAK,WAAW,MAAM,OAAK,UAAW,EAAQ,CAAC,CAAC,CAAC;AAChI,MAAM,OAAO;AAEb,MAAM,UAAU,CAAU,MAA+B,UAAU,CAAC,KAAK,aAAa;AACtF,MAAM,WAAW,CAAC,MAA8C,KAAK,SAAS,OAAO,MAAM,YAAY,OAAO,MAAM,eAAe,CAAC,QAAQ,CAAC;AAE7I,MAAM,SAAS,CAAC,MAAuB,GAAW,SAAU,EAAU,OAAO,IAAI,SAAS,CAAC,IAAI,IAAI;AACnG,MAAM,WAAW,CAAC,MAAyB,GAAW,SAAS;AAE/D,MAAM,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,MAAM,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy-test",
|
|
3
|
-
"version": "15.8.
|
|
3
|
+
"version": "15.8.8",
|
|
4
4
|
"description": "Straightforward library for testing microservices built with @thisisagile/easy",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lint": "yarn g:eslint . --ext .js,.jsx,.ts,.tsx --fix",
|
|
24
24
|
"format": "yarn g:prettier --check --write src test *.json",
|
|
25
25
|
"build": "yarn g:tsc",
|
|
26
|
-
"build:tsup": "yarn g:tsup",
|
|
26
|
+
"build:tsup": "yarn g:tsup --onSuccess \"yarn g:tsc --emitDeclarationOnly --declaration\"",
|
|
27
27
|
"test": "yarn g:jest --coverage",
|
|
28
28
|
"prepack": "yarn g:copy-readme"
|
|
29
29
|
},
|
package/src/utils/Req.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { asNumber,
|
|
1
|
+
import { asNumber, isDefined } from './Utils';
|
|
2
2
|
import { Id, Json, JsonValue, OneOrMore, Text } from './Types';
|
|
3
3
|
|
|
4
4
|
export class Req {
|
|
5
|
-
|
|
5
|
+
readonly skip: number | undefined;
|
|
6
|
+
readonly take: number | undefined;
|
|
7
|
+
constructor(readonly state: any = {}) {
|
|
8
|
+
this.skip = isDefined(this.query?.skip) ? asNumber(this.query?.skip) : undefined;
|
|
9
|
+
this.take = isDefined(this.query?.take) ? asNumber(this.query?.take) : undefined;
|
|
10
|
+
}
|
|
6
11
|
|
|
7
12
|
get id(): Id {
|
|
8
13
|
return this.state.id ?? this.path.id;
|
|
@@ -20,14 +25,6 @@ export class Req {
|
|
|
20
25
|
return this.state?.query ?? {};
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
get skip(): number | undefined {
|
|
24
|
-
return isNumber(this.query?.skip) ? asNumber(this.query?.skip) : undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get take(): number | undefined {
|
|
28
|
-
return isNumber(this.query?.take) ? asNumber(this.query?.take) : undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
28
|
get body(): unknown {
|
|
32
29
|
return this.state.body;
|
|
33
30
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { AsymmetricMatcher } from 'expect';
|
|
2
|
-
|
|
3
|
-
type OneOrMore<T> = T | Array<T>;
|
|
4
|
-
type Constructor<T> = {
|
|
5
|
-
new (...args: any[]): T;
|
|
6
|
-
};
|
|
7
|
-
type Message<P> = Text | ((...params: P[]) => Text);
|
|
8
|
-
type Validatable = {
|
|
9
|
-
isValid: boolean;
|
|
10
|
-
};
|
|
11
|
-
type Result = {
|
|
12
|
-
domain?: string;
|
|
13
|
-
location?: string;
|
|
14
|
-
message: string;
|
|
15
|
-
};
|
|
16
|
-
type Results = Validatable & {
|
|
17
|
-
results: Result[];
|
|
18
|
-
};
|
|
19
|
-
type Uri = Text;
|
|
20
|
-
type Id = string | number;
|
|
21
|
-
type JsonValue = string | number | boolean | null | Json | JsonValue[];
|
|
22
|
-
type Json = {
|
|
23
|
-
[key: string]: JsonValue;
|
|
24
|
-
};
|
|
25
|
-
type Exception = {
|
|
26
|
-
id: Id;
|
|
27
|
-
reason?: string;
|
|
28
|
-
};
|
|
29
|
-
type Text = {
|
|
30
|
-
toString: () => string;
|
|
31
|
-
};
|
|
32
|
-
type Query = Text;
|
|
33
|
-
type UseCase = {
|
|
34
|
-
app: {
|
|
35
|
-
id: Text;
|
|
36
|
-
};
|
|
37
|
-
id: Text;
|
|
38
|
-
};
|
|
39
|
-
type Tester = {
|
|
40
|
-
url: string;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type HttpStatus = {
|
|
44
|
-
name: string;
|
|
45
|
-
id: Id;
|
|
46
|
-
};
|
|
47
|
-
type RestResult = {
|
|
48
|
-
data?: {
|
|
49
|
-
code: number;
|
|
50
|
-
items: unknown[];
|
|
51
|
-
itemCount: number;
|
|
52
|
-
};
|
|
53
|
-
error?: {
|
|
54
|
-
code: number;
|
|
55
|
-
message: string;
|
|
56
|
-
errorCount: number;
|
|
57
|
-
errors: unknown[];
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
type Response = {
|
|
61
|
-
status: HttpStatus;
|
|
62
|
-
headers?: {
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
};
|
|
65
|
-
body?: RestResult;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
declare const toHaveStatus: (res: Response, code: number) => jest.CustomMatcherResult;
|
|
69
|
-
declare const toBeOk: (res: Response) => jest.CustomMatcherResult;
|
|
70
|
-
declare const toBeCreated: (res: Response) => jest.CustomMatcherResult;
|
|
71
|
-
declare const toHaveNoContent: (res: Response) => jest.CustomMatcherResult;
|
|
72
|
-
declare const toBeBadRequest: (res: Response) => jest.CustomMatcherResult;
|
|
73
|
-
declare const toBeUnauthorized: (res: Response) => jest.CustomMatcherResult;
|
|
74
|
-
declare const toBeForbidden: (res: Response) => jest.CustomMatcherResult;
|
|
75
|
-
declare const toBeNotFound: (res: Response) => jest.CustomMatcherResult;
|
|
76
|
-
declare const toBeConflict: (res: Response) => jest.CustomMatcherResult;
|
|
77
|
-
declare const toBeInternalServerError: (res: Response) => jest.CustomMatcherResult;
|
|
78
|
-
declare const toBeBadGateway: (res: Response) => jest.CustomMatcherResult;
|
|
79
|
-
declare const toBeOkWithItems: (res: Response, length: number) => jest.CustomMatcherResult;
|
|
80
|
-
declare global {
|
|
81
|
-
namespace jest {
|
|
82
|
-
interface Matchers<R, T> {
|
|
83
|
-
toBeOk(): R;
|
|
84
|
-
toBeOkWithItems(length: number): R;
|
|
85
|
-
toBeCreated(): R;
|
|
86
|
-
toHaveNoContent(): R;
|
|
87
|
-
toBeNotFound(): R;
|
|
88
|
-
toBeUnauthorized(): R;
|
|
89
|
-
toBeForbidden(): R;
|
|
90
|
-
toBeBadRequest(): R;
|
|
91
|
-
toBeConflict(): R;
|
|
92
|
-
toBeInternalServerError(): R;
|
|
93
|
-
toBeBadGateway(): R;
|
|
94
|
-
toHaveStatus(code: number): R;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
declare class Match<S> {
|
|
100
|
-
private readonly subject;
|
|
101
|
-
private readonly failed;
|
|
102
|
-
private readonly message;
|
|
103
|
-
constructor(subject: S, failed?: boolean, message?: Message<S>);
|
|
104
|
-
not(p: (s: S) => boolean, message: Message<S>): Match<S>;
|
|
105
|
-
undefined(p: (s: S) => any, message: Message<S>): Match<S>;
|
|
106
|
-
else(message: Message<S>): jest.CustomMatcherResult;
|
|
107
|
-
}
|
|
108
|
-
declare const match: <S>(subject: S) => Match<S>;
|
|
109
|
-
|
|
110
|
-
type ToMessage<S> = string | ((s: S[]) => string);
|
|
111
|
-
declare class Check<S> {
|
|
112
|
-
private ctx;
|
|
113
|
-
private readonly received;
|
|
114
|
-
private readonly expected;
|
|
115
|
-
private readonly failed;
|
|
116
|
-
private readonly message;
|
|
117
|
-
constructor(ctx: jest.MatcherContext, received: S, expected: S, failed?: boolean, message?: string);
|
|
118
|
-
print(message: ToMessage<S>): string;
|
|
119
|
-
not(p: (s: S[]) => boolean, message: ToMessage<S>): Check<S>;
|
|
120
|
-
undefined(p: (s: S[]) => any, message: ToMessage<S>): Check<S>;
|
|
121
|
-
else(message?: ToMessage<S>): jest.CustomMatcherResult;
|
|
122
|
-
}
|
|
123
|
-
declare const check: <S>(ctx: jest.MatcherContext, received: S, expected?: S | undefined) => Check<S>;
|
|
124
|
-
declare const checkDefined: <S>(ctx: jest.MatcherContext, received: S, expected?: S | undefined) => Check<S>;
|
|
125
|
-
|
|
126
|
-
declare const toResultWith: (results: Results, message: string) => jest.CustomMatcherResult;
|
|
127
|
-
declare const toFail: (results: Results) => jest.CustomMatcherResult;
|
|
128
|
-
declare const toFailWith: (results: Results, message: string) => jest.CustomMatcherResult;
|
|
129
|
-
declare global {
|
|
130
|
-
namespace jest {
|
|
131
|
-
interface Matchers<R, T> {
|
|
132
|
-
toResultWith(message: string): R;
|
|
133
|
-
toFail(): R;
|
|
134
|
-
toFailWith(message: string): R;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
declare const toBeArrayOf: <T>(items: unknown, ctor: Constructor<T>) => jest.CustomMatcherResult;
|
|
140
|
-
declare global {
|
|
141
|
-
namespace jest {
|
|
142
|
-
interface Matchers<R, T> {
|
|
143
|
-
toBeArrayOf<Z>(ctor: Constructor<Z>): R;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
declare const toBeArrayOfWithLength: <T>(items: unknown, ctor: Constructor<T>, length: number) => jest.CustomMatcherResult;
|
|
149
|
-
declare global {
|
|
150
|
-
namespace jest {
|
|
151
|
-
interface Matchers<R, T> {
|
|
152
|
-
toBeArrayOfWithLength<Z>(ctor: Constructor<Z>, length: number): R;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
declare const toBeAt: (tester?: Tester, uc?: UseCase, id?: Id) => jest.CustomMatcherResult;
|
|
158
|
-
declare global {
|
|
159
|
-
namespace jest {
|
|
160
|
-
interface Matchers<R, T> {
|
|
161
|
-
toBeAt(uc?: UseCase, id?: Id): R;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
declare const toBeExactlyAt: (tester?: Tester, uc?: UseCase, id?: Id) => jest.CustomMatcherResult;
|
|
167
|
-
declare global {
|
|
168
|
-
namespace jest {
|
|
169
|
-
interface Matchers<R, T> {
|
|
170
|
-
toBeExactlyAt(uc?: UseCase, id?: Id): R;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
declare const Fails: {
|
|
176
|
-
Yes: string;
|
|
177
|
-
No: (reason: string) => string;
|
|
178
|
-
};
|
|
179
|
-
declare const FailsWith: {
|
|
180
|
-
Yes: string;
|
|
181
|
-
No: (message: string, instead: string) => string;
|
|
182
|
-
};
|
|
183
|
-
declare const toFailMatcher: (result: jest.CustomMatcherResult) => jest.CustomMatcherResult;
|
|
184
|
-
declare const toFailMatcherWith: (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>) => jest.CustomMatcherResult;
|
|
185
|
-
declare global {
|
|
186
|
-
namespace jest {
|
|
187
|
-
interface Matchers<R, T> {
|
|
188
|
-
toFailMatcher(): R;
|
|
189
|
-
toFailMatcherWith(message: string): R;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
declare const toBeValid: (v?: unknown) => jest.CustomMatcherResult;
|
|
195
|
-
declare global {
|
|
196
|
-
namespace jest {
|
|
197
|
-
interface Matchers<R, T> {
|
|
198
|
-
toBeValid(): R;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
declare function toMatchArray(this: jest.MatcherContext, received: any[], expected: any[]): jest.CustomMatcherResult;
|
|
204
|
-
declare global {
|
|
205
|
-
namespace jest {
|
|
206
|
-
interface Matchers<R, T> {
|
|
207
|
-
toMatchArray(expected: any[]): R;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
declare const MatchesExactJson: {
|
|
213
|
-
SubjectUndefined: string;
|
|
214
|
-
SubsetUndefined: string;
|
|
215
|
-
DoesNotMatch: string;
|
|
216
|
-
Yes: string;
|
|
217
|
-
};
|
|
218
|
-
declare const toMatchExactJson: (value?: unknown, json?: unknown) => jest.CustomMatcherResult;
|
|
219
|
-
declare global {
|
|
220
|
-
namespace jest {
|
|
221
|
-
interface Matchers<R, T> {
|
|
222
|
-
toMatchExactJson(json?: unknown): R;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
declare const toMatchException: (received: Exception, expected: unknown, reason?: string) => jest.CustomMatcherResult;
|
|
228
|
-
declare global {
|
|
229
|
-
namespace jest {
|
|
230
|
-
interface Matchers<R, T> {
|
|
231
|
-
toMatchException(exception: unknown, reason?: string): R;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
declare const MatchesJson: {
|
|
237
|
-
SubjectUndefined: string;
|
|
238
|
-
SubsetUndefined: string;
|
|
239
|
-
DoesNotMatch: string;
|
|
240
|
-
Yes: string;
|
|
241
|
-
};
|
|
242
|
-
declare const toMatchJson: (value?: unknown, subset?: unknown) => jest.CustomMatcherResult;
|
|
243
|
-
declare global {
|
|
244
|
-
namespace jest {
|
|
245
|
-
interface Matchers<R, T> {
|
|
246
|
-
toMatchJson(subset?: unknown): R;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
declare const toMatchRoute: (uri?: Uri, route?: Uri | string) => jest.CustomMatcherResult;
|
|
252
|
-
declare global {
|
|
253
|
-
namespace jest {
|
|
254
|
-
interface Matchers<R, T> {
|
|
255
|
-
toMatchRoute(route?: Uri | string): R;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
declare const toMatchText: (value?: unknown, text?: unknown) => jest.CustomMatcherResult;
|
|
261
|
-
declare global {
|
|
262
|
-
namespace jest {
|
|
263
|
-
interface Matchers<R, T> {
|
|
264
|
-
toMatchText(text?: unknown): R;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
declare const Passes: {
|
|
270
|
-
Yes: string;
|
|
271
|
-
No: (reason: string) => string;
|
|
272
|
-
};
|
|
273
|
-
declare const PassesWith: {
|
|
274
|
-
Yes: string;
|
|
275
|
-
No: (message: string, instead: string) => string;
|
|
276
|
-
};
|
|
277
|
-
declare const toPassMatcher: (result: jest.CustomMatcherResult) => jest.CustomMatcherResult;
|
|
278
|
-
declare const toPassMatcherWith: (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>) => jest.CustomMatcherResult;
|
|
279
|
-
declare global {
|
|
280
|
-
namespace jest {
|
|
281
|
-
interface Matchers<R, T> {
|
|
282
|
-
toPassMatcher(): R;
|
|
283
|
-
toPassMatcherWith(message: string): R;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
declare const toBeQueriedWith: (query: jest.Mock, expected: Query) => jest.CustomMatcherResult;
|
|
289
|
-
declare global {
|
|
290
|
-
namespace jest {
|
|
291
|
-
interface Matchers<R, T> {
|
|
292
|
-
toBeQueriedWith(expected: Query): R;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
declare const toBeRoutedTo: (query: jest.Mock, expected: Uri) => jest.CustomMatcherResult;
|
|
298
|
-
declare global {
|
|
299
|
-
namespace jest {
|
|
300
|
-
interface Matchers<R, T> {
|
|
301
|
-
toBeRoutedTo(uri: Uri): R;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
declare class ObjectContainingText extends AsymmetricMatcher<string> {
|
|
307
|
-
asymmetricMatch(other: any): boolean;
|
|
308
|
-
toString(): string;
|
|
309
|
-
}
|
|
310
|
-
declare class ObjectContainingTextExact extends AsymmetricMatcher<string> {
|
|
311
|
-
asymmetricMatch(other: any): boolean;
|
|
312
|
-
toString(): string;
|
|
313
|
-
}
|
|
314
|
-
declare class ObjectContainingJson extends AsymmetricMatcher<any> {
|
|
315
|
-
asymmetricMatch(other: any): boolean;
|
|
316
|
-
toString(): string;
|
|
317
|
-
}
|
|
318
|
-
declare const fits: {
|
|
319
|
-
any: () => any;
|
|
320
|
-
type: (type?: unknown) => any;
|
|
321
|
-
with: (o: unknown) => any;
|
|
322
|
-
text: (s: any) => any;
|
|
323
|
-
textExact: (s: any) => any;
|
|
324
|
-
uri: (u: Uri) => any;
|
|
325
|
-
json: (s: any) => any;
|
|
326
|
-
items: (...items: any[]) => any;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
declare class Req {
|
|
330
|
-
readonly state: any;
|
|
331
|
-
constructor(state?: any);
|
|
332
|
-
get id(): Id;
|
|
333
|
-
get q(): JsonValue;
|
|
334
|
-
get path(): Json;
|
|
335
|
-
get query(): Json;
|
|
336
|
-
get skip(): number | undefined;
|
|
337
|
-
get take(): number | undefined;
|
|
338
|
-
get body(): unknown;
|
|
339
|
-
get headers(): Record<string, OneOrMore<string>>;
|
|
340
|
-
get: (key: Text) => any;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
declare class Mocks {
|
|
344
|
-
clear: () => typeof jest;
|
|
345
|
-
impl: (f?: ((...args: any[]) => any) | undefined) => jest.Mock;
|
|
346
|
-
property: <T extends object, P extends keyof { [K in keyof Required<T> as Required<T>[K] extends jest.Func ? never : K]: Required<T>[K]; }>(object: T, getter: P, value: T[P]) => jest.SpyInstance;
|
|
347
|
-
reject: (value?: unknown) => jest.Mock;
|
|
348
|
-
rejectWith: <T = any>(props?: Partial<T>) => jest.Mock;
|
|
349
|
-
req: {
|
|
350
|
-
id: (id: Id) => Req;
|
|
351
|
-
q: (q: unknown) => Req;
|
|
352
|
-
with: (a: Json) => Req;
|
|
353
|
-
body: (body: unknown) => Req;
|
|
354
|
-
path: (path: Json) => Req;
|
|
355
|
-
query: (query: Json) => Req;
|
|
356
|
-
};
|
|
357
|
-
resp: {
|
|
358
|
-
items: (status: HttpStatus, items?: unknown[]) => Response;
|
|
359
|
-
errors: (status: HttpStatus, message: string, errors?: unknown[]) => Response;
|
|
360
|
-
};
|
|
361
|
-
resolve: (value?: unknown) => jest.Mock;
|
|
362
|
-
resolveWith: <T = any>(props?: Partial<T>) => jest.Mock;
|
|
363
|
-
return: (value?: unknown) => jest.Mock;
|
|
364
|
-
returnWith: <T = any>(props?: Partial<T>) => jest.Mock;
|
|
365
|
-
this: () => jest.Mock;
|
|
366
|
-
provider: {
|
|
367
|
-
data: (...items: any[]) => {
|
|
368
|
-
execute: jest.Mock;
|
|
369
|
-
};
|
|
370
|
-
};
|
|
371
|
-
empty: <T = any>(props?: Partial<T>) => T;
|
|
372
|
-
a: <T = any>(props?: Partial<T>) => T;
|
|
373
|
-
an: <T = any>(props?: Partial<T>) => T;
|
|
374
|
-
date: (epoch?: number) => Date;
|
|
375
|
-
once: (...values: unknown[]) => jest.Mock;
|
|
376
|
-
}
|
|
377
|
-
declare const mock: Mocks;
|
|
378
|
-
|
|
379
|
-
export { Fails, FailsWith, Match, MatchesExactJson, MatchesJson, Mocks, ObjectContainingJson, ObjectContainingText, ObjectContainingTextExact, Passes, PassesWith, check, checkDefined, fits, match, mock, toBeArrayOf, toBeArrayOfWithLength, toBeAt, toBeBadGateway, toBeBadRequest, toBeConflict, toBeCreated, toBeExactlyAt, toBeForbidden, toBeInternalServerError, toBeNotFound, toBeOk, toBeOkWithItems, toBeQueriedWith, toBeRoutedTo, toBeUnauthorized, toBeValid, toFail, toFailMatcher, toFailMatcherWith, toFailWith, toHaveNoContent, toHaveStatus, toMatchArray, toMatchExactJson, toMatchException, toMatchJson, toMatchRoute, toMatchText, toPassMatcher, toPassMatcherWith, toResultWith };
|