@nestia/e2e 0.3.2 → 0.3.4

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.
@@ -1,87 +1,88 @@
1
- /**
2
- * Test validator.
3
- *
4
- * `TestValidator` is a collection gathering E2E validation functions.
5
- *
6
- * @author Jeongho Nam - https://github.com/samchon
7
- */
8
- export declare namespace TestValidator {
9
- /**
10
- * Test whether condition is satisfied.
11
- *
12
- * @param title Title of error message when condition is not satisfied
13
- * @return Currying function
14
- */
15
- const predicate: (title: string) => <T extends boolean | (() => boolean) | (() => Promise<boolean>)>(condition: T) => T extends () => Promise<boolean> ? Promise<void> : void;
16
- /**
17
- * Test whether two values are equal.
18
- *
19
- * If you want to validate `covers` relationship,
20
- * call smaller first and then larger.
21
- *
22
- * Otherwise you wanna non equals validator, combine with {@link error}.
23
- *
24
- * @param title Title of error message when different
25
- * @returns Currying function
26
- */
27
- const equals: (title: string) => <T>(x: T) => (y: T) => void;
28
- /**
29
- * Test whether error occurs.
30
- *
31
- * If error occurs, nothing would be happened.
32
- *
33
- * However, no error exists, then exception would be thrown.
34
- *
35
- * @param title Title of exception because of no error exists
36
- */
37
- const error: (title: string) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;
38
- const httpError: (title: string) => (status: number) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;
39
- /**
40
- * Validate index API.
41
- *
42
- * Test whether two indexed values are equal.
43
- *
44
- * If two values are different, then exception would be thrown.
45
- *
46
- * @param title Title of error message when different
47
- * @return Currying function
48
- *
49
- * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts
50
- */
51
- const index: (title: string) => <Solution extends IEntity<any>>(expected: Solution[]) => <Summary extends IEntity<any>>(gotten: Summary[], trace?: boolean) => void;
52
- /**
53
- * Valiate search options.
54
- *
55
- * Test a pagination API supporting search options.
56
- *
57
- * @param title Title of error message when searching is invalid
58
- * @returns Currying function
59
- *
60
- * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts
61
- */
62
- const search: (title: string) => <Entity extends IEntity<any>, Request_1>(getter: (input: Request_1) => Promise<Entity[]>) => (total: Entity[], sampleCount?: number) => <Values extends any[]>(props: ISearchProps<Entity, Values, Request_1>) => Promise<void>;
63
- interface ISearchProps<Entity extends IEntity<any>, Values extends any[], Request> {
64
- fields: string[];
65
- values(entity: Entity): Values;
66
- filter(entity: Entity, values: Values): boolean;
67
- request(values: Values): Request;
68
- }
69
- /**
70
- * Validate sorting options.
71
- *
72
- * Test a pagination API supporting sorting options.
73
- *
74
- * You can validate detailed sorting options both asceding and descending orders
75
- * with multiple fields. However, as it forms a complicate currying function,
76
- * I recomend you to see below example code before using.
77
- *
78
- * @param title Title of error message when sorting is invalid
79
- * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts
80
- */
81
- const sort: (title: string) => <T extends object, Fields extends string, Sortable_1 extends (`-${Fields}` | `+${Fields}`)[]>(getter: (sortable: Sortable_1) => Promise<T[]>) => (...fields: Fields[]) => (comp: (x: T, y: T) => number, filter?: ((elem: T) => boolean) | undefined) => (direction: "+" | "-", trace?: boolean) => Promise<void>;
82
- type Sortable<Literal extends string> = Array<`-${Literal}` | `+${Literal}`>;
83
- }
84
- interface IEntity<Type extends string | number | bigint> {
85
- id: Type;
86
- }
87
- export {};
1
+ /**
2
+ * Test validator.
3
+ *
4
+ * `TestValidator` is a collection gathering E2E validation functions.
5
+ *
6
+ * @author Jeongho Nam - https://github.com/samchon
7
+ */
8
+ export declare namespace TestValidator {
9
+ /**
10
+ * Test whether condition is satisfied.
11
+ *
12
+ * @param title Title of error message when condition is not satisfied
13
+ * @return Currying function
14
+ */
15
+ const predicate: (title: string) => <T extends boolean | (() => boolean) | (() => Promise<boolean>)>(condition: T) => T extends () => Promise<boolean> ? Promise<void> : void;
16
+ /**
17
+ * Test whether two values are equal.
18
+ *
19
+ * If you want to validate `covers` relationship,
20
+ * call smaller first and then larger.
21
+ *
22
+ * Otherwise you wanna non equals validator, combine with {@link error}.
23
+ *
24
+ * @param title Title of error message when different
25
+ * @param exception Exception filter for ignoring some keys
26
+ * @returns Currying function
27
+ */
28
+ const equals: (title: string, exception?: (key: string) => boolean) => <T>(x: T) => (y: T) => void;
29
+ /**
30
+ * Test whether error occurs.
31
+ *
32
+ * If error occurs, nothing would be happened.
33
+ *
34
+ * However, no error exists, then exception would be thrown.
35
+ *
36
+ * @param title Title of exception because of no error exists
37
+ */
38
+ const error: (title: string) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;
39
+ const httpError: (title: string) => (status: number) => <T>(task: () => T) => T extends Promise<any> ? Promise<void> : void;
40
+ /**
41
+ * Validate index API.
42
+ *
43
+ * Test whether two indexed values are equal.
44
+ *
45
+ * If two values are different, then exception would be thrown.
46
+ *
47
+ * @param title Title of error message when different
48
+ * @return Currying function
49
+ *
50
+ * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts
51
+ */
52
+ const index: (title: string) => <Solution extends IEntity<any>>(expected: Solution[]) => <Summary extends IEntity<any>>(gotten: Summary[], trace?: boolean) => void;
53
+ /**
54
+ * Valiate search options.
55
+ *
56
+ * Test a pagination API supporting search options.
57
+ *
58
+ * @param title Title of error message when searching is invalid
59
+ * @returns Currying function
60
+ *
61
+ * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts
62
+ */
63
+ const search: (title: string) => <Entity extends IEntity<any>, Request_1>(getter: (input: Request_1) => Promise<Entity[]>) => (total: Entity[], sampleCount?: number) => <Values extends any[]>(props: ISearchProps<Entity, Values, Request_1>) => Promise<void>;
64
+ interface ISearchProps<Entity extends IEntity<any>, Values extends any[], Request> {
65
+ fields: string[];
66
+ values(entity: Entity): Values;
67
+ filter(entity: Entity, values: Values): boolean;
68
+ request(values: Values): Request;
69
+ }
70
+ /**
71
+ * Validate sorting options.
72
+ *
73
+ * Test a pagination API supporting sorting options.
74
+ *
75
+ * You can validate detailed sorting options both asceding and descending orders
76
+ * with multiple fields. However, as it forms a complicate currying function,
77
+ * I recomend you to see below example code before using.
78
+ *
79
+ * @param title Title of error message when sorting is invalid
80
+ * @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts
81
+ */
82
+ const sort: (title: string) => <T extends object, Fields extends string, Sortable_1 extends (`-${Fields}` | `+${Fields}`)[]>(getter: (sortable: Sortable_1) => Promise<T[]>) => (...fields: Fields[]) => (comp: (x: T, y: T) => number, filter?: ((elem: T) => boolean) | undefined) => (direction: "+" | "-", trace?: boolean) => Promise<void>;
83
+ type Sortable<Literal extends string> = Array<`-${Literal}` | `+${Literal}`>;
84
+ }
85
+ interface IEntity<Type extends string | number | bigint> {
86
+ id: Type;
87
+ }
88
+ export {};