@nestia/e2e 0.1.3 → 0.1.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.
- package/lib/TestValidator.d.ts +4 -4
- package/lib/TestValidator.js +3 -8
- package/lib/TestValidator.js.map +1 -1
- package/package.json +1 -1
- package/src/TestValidator.ts +7 -12
package/lib/TestValidator.d.ts
CHANGED
|
@@ -39,12 +39,12 @@ export declare namespace TestValidator {
|
|
|
39
39
|
*
|
|
40
40
|
* @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_search.ts
|
|
41
41
|
*/
|
|
42
|
-
const search: (title: string) => <Entity extends IEntity<any>,
|
|
43
|
-
interface ISearchProps<Entity extends IEntity<any>, Values extends any[],
|
|
42
|
+
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>;
|
|
43
|
+
interface ISearchProps<Entity extends IEntity<any>, Values extends any[], Request> {
|
|
44
44
|
fields: string[];
|
|
45
45
|
values(entity: Entity): Values;
|
|
46
46
|
filter(entity: Entity, values: Values): boolean;
|
|
47
|
-
|
|
47
|
+
request(values: Values): Request;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Validate sorting options.
|
|
@@ -58,7 +58,7 @@ export declare namespace TestValidator {
|
|
|
58
58
|
* @param title Title of error message when sorting is invalid
|
|
59
59
|
* @example https://github.com/samchon/nestia-template/blob/master/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts
|
|
60
60
|
*/
|
|
61
|
-
const sort: (title: string) => <T extends object, Fields extends string, Sortable_1 extends (`-${Fields}` | `+${Fields}`)[]>(getter: (sortable: Sortable_1) => Promise<T[]
|
|
61
|
+
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>;
|
|
62
62
|
type Sortable<Literal extends string> = Array<`-${Literal}` | `+${Literal}`>;
|
|
63
63
|
}
|
|
64
64
|
interface IEntity<Type extends string | number | bigint> {
|
package/lib/TestValidator.js
CHANGED
|
@@ -136,9 +136,8 @@ var TestValidator;
|
|
|
136
136
|
TestValidator.search = function (title) {
|
|
137
137
|
/**
|
|
138
138
|
* @param getter A pagination API function to be called
|
|
139
|
-
* @param validator Validator function if required
|
|
140
139
|
*/
|
|
141
|
-
return function (getter
|
|
140
|
+
return function (getter) {
|
|
142
141
|
/**
|
|
143
142
|
* @param total Total entity records for comparison
|
|
144
143
|
* @param sampleCount Sampling count. Default is 1
|
|
@@ -164,11 +163,9 @@ var TestValidator;
|
|
|
164
163
|
filtered = total.filter(function (entity) {
|
|
165
164
|
return props.filter(entity, values);
|
|
166
165
|
});
|
|
167
|
-
return [4 /*yield*/, getter(props.
|
|
166
|
+
return [4 /*yield*/, getter(props.request(values))];
|
|
168
167
|
case 1:
|
|
169
168
|
gotten = _c.sent();
|
|
170
|
-
if (validator)
|
|
171
|
-
validator(gotten);
|
|
172
169
|
TestValidator.index("".concat(title, " (").concat(props.fields.join(", "), ")"))(filtered)(gotten);
|
|
173
170
|
return [2 /*return*/];
|
|
174
171
|
}
|
|
@@ -223,7 +220,7 @@ var TestValidator;
|
|
|
223
220
|
/**
|
|
224
221
|
* @param getter A pagination API function to be called
|
|
225
222
|
*/
|
|
226
|
-
return function (getter
|
|
223
|
+
return function (getter) {
|
|
227
224
|
/**
|
|
228
225
|
* @param fields List of fields to be sorted
|
|
229
226
|
*/
|
|
@@ -249,8 +246,6 @@ var TestValidator;
|
|
|
249
246
|
case 0: return [4 /*yield*/, getter(fields.map(function (field) { return "".concat(direction).concat(field); }))];
|
|
250
247
|
case 1:
|
|
251
248
|
data = _a.sent();
|
|
252
|
-
if (validator)
|
|
253
|
-
validator(data);
|
|
254
249
|
if (filter)
|
|
255
250
|
data = data.filter(filter);
|
|
256
251
|
reversed = direction === "+" ? comp : function (x, y) { return comp(y, x); };
|
package/lib/TestValidator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestValidator.js","sourceRoot":"","sources":["../src/TestValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAwC;AAExC,qDAAoD;AAEpD;;;;;;GAMG;AACH,IAAiB,aAAa,
|
|
1
|
+
{"version":3,"file":"TestValidator.js","sourceRoot":"","sources":["../src/TestValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAwC;AAExC,qDAAoD;AAEpD;;;;;;GAMG;AACH,IAAiB,aAAa,CAuL7B;AAvLD,WAAiB,aAAa;;IAC1B;;;;;;;;OAQG;IACU,mBAAK,GACd,UAAC,KAAa;QACd,OAAA,UAAO,IAA8B;;;;;;wBAE7B,qBAAM,IAAI,EAAE,EAAA;;wBAAZ,SAAY,CAAC;;;;wBAEb,sBAAO;4BAEX,MAAM,IAAI,KAAK,CAAC,iBAAU,KAAK,gCAA6B,CAAC,CAAC;;;aACjE;IAPD,CAOC,CAAC;IAEN;;;;;;;;;;;OAWG;IACU,mBAAK,GACd,UAAC,KAAa;QACd,OAAA,UAAgC,QAAoB;YACpD,OAAA,UACI,MAAiB,EACjB,KAAqB;gBAArB,sBAAA,EAAA,YAAqB;gBAErB,IAAM,MAAM,GAAW,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBAChE,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;gBACrC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EA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,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAlB,CAAkB,CAAC,KAAK,KAAK,EAAE;4CACzD,IACI,MAAM,CAAC,MAAM,KAAK,CAAC;gDACnB,IAAI,CAAC,MAAM;gDACV,IAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS;gDACzC,KAAK;gDAEL,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAC,IAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAxB,CAAwB,CAAC,CAAC,CAAC;4CAC9D,MAAM,IAAI,KAAK,CACX,iBAAU,KAAK,gCAAsB,SAAS,cAAI,MAAM,CAAC,IAAI,CACzD,IAAI,CACP,OAAI,CACR,CAAC;yCACL;;;;;qBACJ;gBAxBD,CAwBC;YA5BD,CA4BC;QAjCD,CAiCC;IA3CD,CA2CC,CAAC;AAKV,CAAC,EAvLgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAuL7B;AAMD,SAAS,OAAO,CAA8B,QAAkB;IAC5D,OAAO,QAAQ,CAAC,GAAG,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,EAAE,EAAT,CAAS,CAAC,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAhB,CAAgB,CAAC,CAAC;AAChF,CAAC"}
|
package/package.json
CHANGED
package/src/TestValidator.ts
CHANGED
|
@@ -84,11 +84,9 @@ export namespace TestValidator {
|
|
|
84
84
|
(title: string) =>
|
|
85
85
|
/**
|
|
86
86
|
* @param getter A pagination API function to be called
|
|
87
|
-
* @param validator Validator function if required
|
|
88
87
|
*/
|
|
89
|
-
<Entity extends IEntity<any>,
|
|
90
|
-
getter: (input:
|
|
91
|
-
validator?: (data: Entity[]) => any,
|
|
88
|
+
<Entity extends IEntity<any>, Request>(
|
|
89
|
+
getter: (input: Request) => Promise<Entity[]>,
|
|
92
90
|
) =>
|
|
93
91
|
/**
|
|
94
92
|
* @param total Total entity records for comparison
|
|
@@ -99,8 +97,8 @@ export namespace TestValidator {
|
|
|
99
97
|
* @param props Search properties
|
|
100
98
|
*/
|
|
101
99
|
async <Values extends any[]>(
|
|
102
|
-
props: ISearchProps<Entity, Values,
|
|
103
|
-
) => {
|
|
100
|
+
props: ISearchProps<Entity, Values, Request>,
|
|
101
|
+
): Promise<void> => {
|
|
104
102
|
const samples: Entity[] = RandomGenerator.sample(
|
|
105
103
|
total,
|
|
106
104
|
sampleCount,
|
|
@@ -110,8 +108,7 @@ export namespace TestValidator {
|
|
|
110
108
|
const filtered: Entity[] = total.filter((entity) =>
|
|
111
109
|
props.filter(entity, values),
|
|
112
110
|
);
|
|
113
|
-
const gotten: Entity[] = await getter(props.
|
|
114
|
-
if (validator) validator(gotten);
|
|
111
|
+
const gotten: Entity[] = await getter(props.request(values));
|
|
115
112
|
|
|
116
113
|
TestValidator.index(`${title} (${props.fields.join(", ")})`)(
|
|
117
114
|
filtered,
|
|
@@ -122,12 +119,12 @@ export namespace TestValidator {
|
|
|
122
119
|
export interface ISearchProps<
|
|
123
120
|
Entity extends IEntity<any>,
|
|
124
121
|
Values extends any[],
|
|
125
|
-
|
|
122
|
+
Request,
|
|
126
123
|
> {
|
|
127
124
|
fields: string[];
|
|
128
125
|
values(entity: Entity): Values;
|
|
129
126
|
filter(entity: Entity, values: Values): boolean;
|
|
130
|
-
|
|
127
|
+
request(values: Values): Request;
|
|
131
128
|
}
|
|
132
129
|
|
|
133
130
|
/**
|
|
@@ -153,7 +150,6 @@ export namespace TestValidator {
|
|
|
153
150
|
Sortable extends Array<`-${Fields}` | `+${Fields}`>,
|
|
154
151
|
>(
|
|
155
152
|
getter: (sortable: Sortable) => Promise<T[]>,
|
|
156
|
-
validator?: (data: T[]) => any,
|
|
157
153
|
) =>
|
|
158
154
|
/**
|
|
159
155
|
* @param fields List of fields to be sorted
|
|
@@ -173,7 +169,6 @@ export namespace TestValidator {
|
|
|
173
169
|
(field) => `${direction}${field}` as const,
|
|
174
170
|
) as Sortable,
|
|
175
171
|
);
|
|
176
|
-
if (validator) validator(data);
|
|
177
172
|
if (filter) data = data.filter(filter);
|
|
178
173
|
|
|
179
174
|
const reversed: typeof comp =
|