milkio 0.0.6 → 0.0.7
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.
|
@@ -38,13 +38,14 @@ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof sch
|
|
|
38
38
|
const csStartedAt = new Date().getTime();
|
|
39
39
|
const clear = setTimeout(() => {
|
|
40
40
|
console.error(`------`);
|
|
41
|
-
console.error(`❌ TIMEOUT -- More than ${cs.timeout ??
|
|
41
|
+
console.error(`❌ TIMEOUT -- More than ${cs.timeout ?? 8192}ms`);
|
|
42
42
|
console.error(` ${cs.name} | Path: src/apps/${path as string}.ts | Case: ${i}`);
|
|
43
43
|
console.error(`------`);
|
|
44
44
|
exit(1);
|
|
45
|
-
}, cs.timeout ??
|
|
45
|
+
}, cs.timeout ?? 8192);
|
|
46
46
|
await cs.handler({
|
|
47
47
|
execute: async (params: any, headers?: any, options?: any) => app.execute(path, params, headers ?? {}, options),
|
|
48
|
+
executeOther: async (path: any, params: any, headers?: any, options?: any) => app.execute(path, params, headers ?? {}, options),
|
|
48
49
|
reject: (message?: string) => {
|
|
49
50
|
console.error(`------`);
|
|
50
51
|
console.error(`❌ REJECT -- ${message ?? "Test not satisfied"}`);
|
|
@@ -52,7 +53,7 @@ export const defineApiTestHandler = async <Paths extends Array<keyof (typeof sch
|
|
|
52
53
|
console.error(`------`);
|
|
53
54
|
exit(1);
|
|
54
55
|
}
|
|
55
|
-
});
|
|
56
|
+
} as any);
|
|
56
57
|
clearTimeout(clear);
|
|
57
58
|
console.log(`✅ DIRECT -- ${cs.name} | Path: src/apps/${path as string}.ts | Case: ${i} | Time: ${new Date().getTime() - csStartedAt}ms`);
|
|
58
59
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Api, type ExecuteResult, type ExecuteOptions } from "..";
|
|
2
|
+
import type schema from "../../../generate/api-schema";
|
|
2
3
|
|
|
3
4
|
export function defineApiTest<ApiT extends Api>(_api: ApiT, cases: Array<ApiTestCases<ApiT>>) {
|
|
4
5
|
return {
|
|
@@ -8,7 +9,14 @@ export function defineApiTest<ApiT extends Api>(_api: ApiT, cases: Array<ApiTest
|
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export type ApiTestCases<ApiT extends Api> = {
|
|
11
|
-
handler: (test: {
|
|
12
|
+
handler: (test: {
|
|
13
|
+
// execute
|
|
14
|
+
execute: (params: Parameters<ApiT["action"]>[0], headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Awaited<ReturnType<ApiT["action"]>>>>;
|
|
15
|
+
// execute other
|
|
16
|
+
executeOther: <Path extends keyof (typeof schema)["apiMethodsTypeSchema"], Result extends Awaited<ReturnType<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>>>(path: Path, params: Parameters<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>[0] | string, headers?: Record<string, string>, options?: ExecuteOptions) => Promise<ExecuteResult<Result>>;
|
|
17
|
+
// reject
|
|
18
|
+
reject: (message?: string) => void;
|
|
19
|
+
}) => Promise<void> | void;
|
|
12
20
|
name: string;
|
|
13
21
|
timeout?: number;
|
|
14
22
|
};
|