@locustjs/test 2.0.0 → 2.0.1
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.js +2198 -1555
- package/package.json +5 -3
- package/rollup.config.js +11 -2
- package/tests/index.js +3 -3
package/dist/index.js
CHANGED
|
@@ -5,1566 +5,2209 @@ var fs = require('fs');
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var exception = require('@locustjs/exception');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.value = value;
|
|
13
|
-
this._expected = false;
|
|
14
|
-
}
|
|
15
|
-
get expected() {
|
|
16
|
-
return this._expected;
|
|
17
|
-
}
|
|
18
|
-
toBe(value) {
|
|
19
|
-
this._expected = true;
|
|
20
|
-
|
|
21
|
-
if (this.value === value) ; else {
|
|
22
|
-
throw new TestException({
|
|
23
|
-
message: `${this.value} is not equal to ${value}`,
|
|
24
|
-
code: 1000,
|
|
25
|
-
status: "not-eq",
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
notToBe(value) {
|
|
32
|
-
this._expected = true;
|
|
33
|
-
|
|
34
|
-
if (this.value === value) {
|
|
35
|
-
throw new TestException({
|
|
36
|
-
message: `${value} is equal to ${this.value}`,
|
|
37
|
-
code: 1005,
|
|
38
|
-
status: "eq",
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
toBeGt(value) {
|
|
45
|
-
this._expected = true;
|
|
46
|
-
|
|
47
|
-
if (this.value <= value) {
|
|
48
|
-
throw new TestException({
|
|
49
|
-
message: `${this.value} is not greater than ${value}`,
|
|
50
|
-
code: 1001,
|
|
51
|
-
status: "lte",
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
toBeGreaterThan(value) {
|
|
58
|
-
return this.toBeGt(value);
|
|
59
|
-
}
|
|
60
|
-
toBeGte(value) {
|
|
61
|
-
this._expected = true;
|
|
62
|
-
|
|
63
|
-
if (this.value < value) {
|
|
64
|
-
throw new TestException({
|
|
65
|
-
message: `${this.value} is not greater than or equal to ${value}`,
|
|
66
|
-
code: 1002,
|
|
67
|
-
status: "lt",
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
toBeGreaterThanOrEqualTo(value) {
|
|
74
|
-
return this.toBeGte(value);
|
|
75
|
-
}
|
|
76
|
-
toBeLt(value) {
|
|
77
|
-
this._expected = true;
|
|
78
|
-
|
|
79
|
-
if (this.value >= value) {
|
|
80
|
-
throw new TestException({
|
|
81
|
-
message: `${this.value} is not less than ${value}`,
|
|
82
|
-
code: 1003,
|
|
83
|
-
status: "gte",
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
toBeLowerThan(value) {
|
|
90
|
-
return this.toBeLt(value);
|
|
91
|
-
}
|
|
92
|
-
toBeLte(value) {
|
|
93
|
-
this._expected = true;
|
|
94
|
-
|
|
95
|
-
if (this.value > value) {
|
|
96
|
-
throw new TestException({
|
|
97
|
-
message: `${this.value} is not less than or equal to ${value}`,
|
|
98
|
-
code: 1004,
|
|
99
|
-
status: "gt",
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
toBeLowerThanOrEqualTo(value) {
|
|
106
|
-
return this.toBeLte(value);
|
|
107
|
-
}
|
|
108
|
-
toBeBetween(n, m) {
|
|
109
|
-
this._expected = true;
|
|
110
|
-
|
|
111
|
-
if (!(this.value >= n && this.value < m)) {
|
|
112
|
-
throw new TestException({
|
|
113
|
-
message: `${this.value} is not between ${n} and ${m}`,
|
|
114
|
-
code: 1024,
|
|
115
|
-
status: "between",
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
notToBeBetween(n, m) {
|
|
122
|
-
this._expected = true;
|
|
123
|
-
|
|
124
|
-
if (this.value >= n && this.value < m) {
|
|
125
|
-
throw new TestException({
|
|
126
|
-
message: `${this.value} is between ${n} and ${m}`,
|
|
127
|
-
code: 1044,
|
|
128
|
-
status: "not-between",
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
toBeOfType(type) {
|
|
135
|
-
this._expected = true;
|
|
136
|
-
|
|
137
|
-
if (typeof this.value !== type) {
|
|
138
|
-
throw new TestException({
|
|
139
|
-
message: `${this.value} is not of type ${type}`,
|
|
140
|
-
code: 1025,
|
|
141
|
-
status: "of-type",
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
notToBeOfType(type) {
|
|
148
|
-
this._expected = true;
|
|
149
|
-
|
|
150
|
-
if (typeof this.value === type) {
|
|
151
|
-
throw new TestException({
|
|
152
|
-
message: `${this.value} is of type ${type}`,
|
|
153
|
-
code: 1045,
|
|
154
|
-
status: "not-oftype",
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
toBeString() {
|
|
161
|
-
this._expected = true;
|
|
162
|
-
|
|
163
|
-
if (!base.isString(this.value)) {
|
|
164
|
-
throw new TestException({
|
|
165
|
-
message: `${this.value} is not string`,
|
|
166
|
-
code: 1026,
|
|
167
|
-
status: "is-string",
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
notToBeString() {
|
|
174
|
-
this._expected = true;
|
|
175
|
-
|
|
176
|
-
if (base.isString(this.value)) {
|
|
177
|
-
throw new TestException({
|
|
178
|
-
message: `${this.value} is string`,
|
|
179
|
-
code: 1046,
|
|
180
|
-
status: "not-is-string",
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return this;
|
|
185
|
-
}
|
|
186
|
-
toBeSomeString() {
|
|
187
|
-
this._expected = true;
|
|
188
|
-
if (!base.isSomeString(this.value)) {
|
|
189
|
-
throw new TestException({
|
|
190
|
-
message: `${this.value} is not some string`,
|
|
191
|
-
code: 1027,
|
|
192
|
-
status: "is-some-string",
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
notToBeSomeString() {
|
|
199
|
-
this._expected = true;
|
|
200
|
-
|
|
201
|
-
if (base.isSomeString(this.value)) {
|
|
202
|
-
throw new TestException({
|
|
203
|
-
message: `${this.value} is some string`,
|
|
204
|
-
code: 1047,
|
|
205
|
-
status: "not-is-some-string",
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return this;
|
|
210
|
-
}
|
|
211
|
-
toBeNumber() {
|
|
212
|
-
this._expected = true;
|
|
213
|
-
|
|
214
|
-
if (!base.isNumber(this.value)) {
|
|
215
|
-
throw new TestException({
|
|
216
|
-
message: `${this.value} is not number`,
|
|
217
|
-
code: 1028,
|
|
218
|
-
status: "is-number",
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return this;
|
|
223
|
-
}
|
|
224
|
-
notToBeNumber() {
|
|
225
|
-
this._expected = true;
|
|
226
|
-
|
|
227
|
-
if (base.isNumber(this.value)) {
|
|
228
|
-
throw new TestException({
|
|
229
|
-
message: `${this.value} is number`,
|
|
230
|
-
code: 1048,
|
|
231
|
-
status: "not-is-number",
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return this;
|
|
236
|
-
}
|
|
237
|
-
toBeDate() {
|
|
238
|
-
this._expected = true;
|
|
239
|
-
|
|
240
|
-
if (!base.isDate(this.value)) {
|
|
241
|
-
throw new TestException({
|
|
242
|
-
message: `${this.value} is not date`,
|
|
243
|
-
code: 1029,
|
|
244
|
-
status: "is-date",
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return this;
|
|
249
|
-
}
|
|
250
|
-
notToBeDate() {
|
|
251
|
-
this._expected = true;
|
|
252
|
-
|
|
253
|
-
if (base.isDate(this.value)) {
|
|
254
|
-
throw new TestException({
|
|
255
|
-
message: `${this.value} is date`,
|
|
256
|
-
code: 1049,
|
|
257
|
-
status: "not-is-date",
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return this;
|
|
262
|
-
}
|
|
263
|
-
toBeBool() {
|
|
264
|
-
this._expected = true;
|
|
265
|
-
|
|
266
|
-
if (!base.isBool(this.value)) {
|
|
267
|
-
throw new TestException({
|
|
268
|
-
message: `${this.value} is not bool`,
|
|
269
|
-
code: 1030,
|
|
270
|
-
status: "is-bool",
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return this;
|
|
275
|
-
}
|
|
276
|
-
notToBeBool() {
|
|
277
|
-
this._expected = true;
|
|
278
|
-
|
|
279
|
-
if (base.isBool(this.value)) {
|
|
280
|
-
throw new TestException({
|
|
281
|
-
message: `${this.value} is bool`,
|
|
282
|
-
code: 1050,
|
|
283
|
-
status: "not-is-bool",
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return this;
|
|
288
|
-
}
|
|
289
|
-
toBeBasicType() {
|
|
290
|
-
this._expected = true;
|
|
291
|
-
|
|
292
|
-
if (!base.isBasic(this.value)) {
|
|
293
|
-
throw new TestException({
|
|
294
|
-
message: `${this.value} is not basic type`,
|
|
295
|
-
code: 1031,
|
|
296
|
-
status: "is-basic-type",
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return this;
|
|
301
|
-
}
|
|
302
|
-
notToBeBasicType() {
|
|
303
|
-
this._expected = true;
|
|
304
|
-
|
|
305
|
-
if (base.isBasic(this.value)) {
|
|
306
|
-
throw new TestException({
|
|
307
|
-
message: `${this.value} is basic type`,
|
|
308
|
-
code: 1051,
|
|
309
|
-
status: "not-is-basic-type",
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return this;
|
|
314
|
-
}
|
|
315
|
-
toBePrimitive() {
|
|
316
|
-
this._expected = true;
|
|
317
|
-
|
|
318
|
-
if (!base.isPrimitive(this.value)) {
|
|
319
|
-
throw new TestException({
|
|
320
|
-
message: `${this.value} is not primitive type`,
|
|
321
|
-
code: 1032,
|
|
322
|
-
status: "is-primitive",
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return this;
|
|
327
|
-
}
|
|
328
|
-
notToBePrimitive() {
|
|
329
|
-
this._expected = true;
|
|
330
|
-
|
|
331
|
-
if (base.isPrimitive(this.value)) {
|
|
332
|
-
throw new TestException({
|
|
333
|
-
message: `${this.value} is primitive type`,
|
|
334
|
-
code: 1052,
|
|
335
|
-
status: "not-is-primitive",
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return this;
|
|
340
|
-
}
|
|
341
|
-
toBeEmpty() {
|
|
342
|
-
this._expected = true;
|
|
343
|
-
|
|
344
|
-
if (!base.isEmpty(this.value)) {
|
|
345
|
-
throw new TestException({
|
|
346
|
-
message: `${this.value} is not empty`,
|
|
347
|
-
code: 1033,
|
|
348
|
-
status: "is-empty",
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return this;
|
|
353
|
-
}
|
|
354
|
-
notToBeEmpty() {
|
|
355
|
-
this._expected = true;
|
|
356
|
-
|
|
357
|
-
if (base.isEmpty(this.value)) {
|
|
358
|
-
throw new TestException({
|
|
359
|
-
message: `${this.value} is empty`,
|
|
360
|
-
code: 1053,
|
|
361
|
-
status: "not-is-empty",
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return this;
|
|
366
|
-
}
|
|
367
|
-
toBeObject() {
|
|
368
|
-
this._expected = true;
|
|
369
|
-
|
|
370
|
-
if (!base.isObject(this.value)) {
|
|
371
|
-
throw new TestException({
|
|
372
|
-
message: `${this.value} is not object`,
|
|
373
|
-
code: 1034,
|
|
374
|
-
status: "is-object",
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
return this;
|
|
379
|
-
}
|
|
380
|
-
notToBeObject() {
|
|
381
|
-
this._expected = true;
|
|
382
|
-
|
|
383
|
-
if (base.isObject(this.value)) {
|
|
384
|
-
throw new TestException({
|
|
385
|
-
message: `${this.value} is object`,
|
|
386
|
-
code: 1054,
|
|
387
|
-
status: "not-is-object",
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
return this;
|
|
392
|
-
}
|
|
393
|
-
toBeSomeObject() {
|
|
394
|
-
this._expected = true;
|
|
395
|
-
|
|
396
|
-
if (!base.isSomeObject(this.value)) {
|
|
397
|
-
throw new TestException({
|
|
398
|
-
message: `${this.value} is not some object`,
|
|
399
|
-
code: 1035,
|
|
400
|
-
status: "is-some-object",
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
return this;
|
|
405
|
-
}
|
|
406
|
-
notToBeSomeObject() {
|
|
407
|
-
this._expected = true;
|
|
408
|
-
|
|
409
|
-
if (base.isSomeObject(this.value)) {
|
|
410
|
-
throw new TestException({
|
|
411
|
-
message: `${this.value} is some object`,
|
|
412
|
-
code: 1055,
|
|
413
|
-
status: "not-is-some-object",
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return this;
|
|
418
|
-
}
|
|
419
|
-
toBeFunction() {
|
|
420
|
-
this._expected = true;
|
|
421
|
-
|
|
422
|
-
if (!base.isFunction(this.value)) {
|
|
423
|
-
throw new TestException({
|
|
424
|
-
message: `${this.value} is not function`,
|
|
425
|
-
code: 1036,
|
|
426
|
-
status: "is-function",
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return this;
|
|
431
|
-
}
|
|
432
|
-
notToBeFunction() {
|
|
433
|
-
this._expected = true;
|
|
434
|
-
|
|
435
|
-
if (base.isFunction(this.value)) {
|
|
436
|
-
throw new TestException({
|
|
437
|
-
message: `${this.value} is function`,
|
|
438
|
-
code: 1056,
|
|
439
|
-
status: "not-is-function",
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
return this;
|
|
444
|
-
}
|
|
445
|
-
toBeNumeric() {
|
|
446
|
-
this._expected = true;
|
|
447
|
-
|
|
448
|
-
if (!base.isNumeric(this.value)) {
|
|
449
|
-
throw new TestException({
|
|
450
|
-
message: `${this.value} is not numeric`,
|
|
451
|
-
code: 1037,
|
|
452
|
-
status: "is-numeric",
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
return this;
|
|
457
|
-
}
|
|
458
|
-
notToBeNumeric() {
|
|
459
|
-
this._expected = true;
|
|
460
|
-
|
|
461
|
-
if (base.isNumeric(this.value)) {
|
|
462
|
-
throw new TestException({
|
|
463
|
-
message: `${this.value} is numeric`,
|
|
464
|
-
code: 1057,
|
|
465
|
-
status: "not-is-numeric",
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return this;
|
|
470
|
-
}
|
|
471
|
-
toBeArray() {
|
|
472
|
-
this._expected = true;
|
|
473
|
-
|
|
474
|
-
if (!base.isArray(this.value)) {
|
|
475
|
-
throw new TestException({
|
|
476
|
-
message: `${this.value} is not array`,
|
|
477
|
-
code: 1038,
|
|
478
|
-
status: "is-array",
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return this;
|
|
483
|
-
}
|
|
484
|
-
notToBeArray() {
|
|
485
|
-
this._expected = true;
|
|
486
|
-
|
|
487
|
-
if (base.isArray(this.value)) {
|
|
488
|
-
throw new TestException({
|
|
489
|
-
message: `${this.value} is array`,
|
|
490
|
-
code: 1058,
|
|
491
|
-
status: "not-is-array",
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
return this;
|
|
496
|
-
}
|
|
497
|
-
toBeSomeArray() {
|
|
498
|
-
this._expected = true;
|
|
499
|
-
|
|
500
|
-
if (!base.isSomeArray(this.value)) {
|
|
501
|
-
throw new TestException({
|
|
502
|
-
message: `${this.value} is not some array`,
|
|
503
|
-
code: 1039,
|
|
504
|
-
status: "is-some-array",
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
return this;
|
|
509
|
-
}
|
|
510
|
-
notToBeSomeArray() {
|
|
511
|
-
this._expected = true;
|
|
512
|
-
|
|
513
|
-
if (!base.isArray(this.value)) {
|
|
514
|
-
throw new TestException({
|
|
515
|
-
message: `${this.value} is not array`,
|
|
516
|
-
code: 1068,
|
|
517
|
-
status: "is-not-array",
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
if (this.value.length) {
|
|
521
|
-
throw new TestException({
|
|
522
|
-
message: `${this.value} is array`,
|
|
523
|
-
code: 1069,
|
|
524
|
-
status: "is-some-array",
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
return this;
|
|
529
|
-
}
|
|
530
|
-
toBeIterable() {
|
|
531
|
-
this._expected = true;
|
|
532
|
-
|
|
533
|
-
if (!base.isIterable(this.value)) {
|
|
534
|
-
throw new TestException({
|
|
535
|
-
message: `${this.value} is not iterable`,
|
|
536
|
-
code: 1040,
|
|
537
|
-
status: "is-iterable",
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
return this;
|
|
542
|
-
}
|
|
543
|
-
notToBeIterable() {
|
|
544
|
-
this._expected = true;
|
|
545
|
-
|
|
546
|
-
if (base.isIterable(this.value)) {
|
|
547
|
-
throw new TestException({
|
|
548
|
-
message: `${this.value} is iterable`,
|
|
549
|
-
code: 1060,
|
|
550
|
-
status: "not-iterable",
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
return this;
|
|
555
|
-
}
|
|
556
|
-
toBeSubClassOf(type) {
|
|
557
|
-
this._expected = true;
|
|
558
|
-
|
|
559
|
-
if (!base.isSubClassOf(this.value, type)) {
|
|
560
|
-
throw new TestException({
|
|
561
|
-
message: `${this.value} is not subclass of ${type}`,
|
|
562
|
-
code: 1041,
|
|
563
|
-
status: "is-subclass-of",
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
return this;
|
|
568
|
-
}
|
|
569
|
-
notToBeSubClassOf(type) {
|
|
570
|
-
this._expected = true;
|
|
571
|
-
|
|
572
|
-
if (base.isSubClassOf(this.value, type)) {
|
|
573
|
-
throw new TestException({
|
|
574
|
-
message: `${this.value} is subclass of ${type}`,
|
|
575
|
-
code: 1061,
|
|
576
|
-
status: "not-subclassof",
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
return this;
|
|
581
|
-
}
|
|
582
|
-
toBeInstanceOf(type) {
|
|
583
|
-
this._expected = true;
|
|
584
|
-
|
|
585
|
-
if (!(this.value instanceof type)) {
|
|
586
|
-
throw new TestException({
|
|
587
|
-
message: `${this.value} is not instance of ${type}`,
|
|
588
|
-
code: 1042,
|
|
589
|
-
status: "instanceof",
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
return this;
|
|
594
|
-
}
|
|
595
|
-
notToBeInstanceOf(type) {
|
|
596
|
-
this._expected = true;
|
|
597
|
-
|
|
598
|
-
if (this.value instanceof type) {
|
|
599
|
-
throw new TestException({
|
|
600
|
-
message: `${this.value} is instance of ${type}`,
|
|
601
|
-
code: 1062,
|
|
602
|
-
status: "not-instanceof",
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
return this;
|
|
607
|
-
}
|
|
608
|
-
toMatch(pattern, flags) {
|
|
609
|
-
this._expected = true;
|
|
610
|
-
|
|
611
|
-
const r = new RegExp(pattern, flags);
|
|
612
|
-
|
|
613
|
-
if (!r.test(this.value)) {
|
|
614
|
-
throw new TestException({
|
|
615
|
-
message: `${this.value} does not match ${pattern}`,
|
|
616
|
-
code: 1043,
|
|
617
|
-
status: "match",
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
return this;
|
|
622
|
-
}
|
|
623
|
-
notToMatch(pattern, flags) {
|
|
624
|
-
this._expected = true;
|
|
625
|
-
|
|
626
|
-
const r = new RegExp(pattern, flags);
|
|
627
|
-
|
|
628
|
-
if (r.test(this.value)) {
|
|
629
|
-
throw new TestException({
|
|
630
|
-
message: `${this.value} matches ${pattern}`,
|
|
631
|
-
code: 1070,
|
|
632
|
-
status: "match",
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
return this;
|
|
637
|
-
}
|
|
638
|
-
doesNotMatch(pattern, flags) {
|
|
639
|
-
this._expected = true;
|
|
640
|
-
|
|
641
|
-
const r = new RegExp(pattern, flags);
|
|
642
|
-
|
|
643
|
-
if (r.test(this.value)) {
|
|
644
|
-
throw new TestException({
|
|
645
|
-
message: `${this.value} matches ${pattern}`,
|
|
646
|
-
code: 1063,
|
|
647
|
-
status: "not-match",
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
return this;
|
|
652
|
-
}
|
|
653
|
-
toBeDefined() {
|
|
654
|
-
this._expected = true;
|
|
655
|
-
|
|
656
|
-
if (this.value === undefined) {
|
|
657
|
-
throw new TestException({
|
|
658
|
-
message: `value is undefined`,
|
|
659
|
-
code: 1006,
|
|
660
|
-
status: "undefined",
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
return this;
|
|
665
|
-
}
|
|
666
|
-
notToBeDefined() {
|
|
667
|
-
this._expected = true;
|
|
668
|
-
|
|
669
|
-
if (this.value !== undefined) {
|
|
670
|
-
throw new TestException({
|
|
671
|
-
message: `value is defined`,
|
|
672
|
-
code: 1071,
|
|
673
|
-
status: "defined",
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
return this;
|
|
678
|
-
}
|
|
679
|
-
toBeUndefined() {
|
|
680
|
-
this._expected = true;
|
|
681
|
-
|
|
682
|
-
if (this.value !== undefined) {
|
|
683
|
-
throw new TestException({
|
|
684
|
-
message: `value is defined`,
|
|
685
|
-
code: 1007,
|
|
686
|
-
status: "defined",
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
return this;
|
|
691
|
-
}
|
|
692
|
-
notToBeUndefined() {
|
|
693
|
-
this._expected = true;
|
|
694
|
-
|
|
695
|
-
if (this.value === undefined) {
|
|
696
|
-
throw new TestException({
|
|
697
|
-
message: `value is undefined`,
|
|
698
|
-
code: 1072,
|
|
699
|
-
status: "undefined",
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
return this;
|
|
704
|
-
}
|
|
705
|
-
toBeNull() {
|
|
706
|
-
this._expected = true;
|
|
707
|
-
|
|
708
|
-
if (this.value !== null) {
|
|
709
|
-
throw new TestException({
|
|
710
|
-
message: `value is not null`,
|
|
711
|
-
code: 1008,
|
|
712
|
-
status: "not-null",
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
return this;
|
|
717
|
-
}
|
|
718
|
-
notToBeNull() {
|
|
719
|
-
this._expected = true;
|
|
720
|
-
|
|
721
|
-
if (this.value === null) {
|
|
722
|
-
throw new TestException({
|
|
723
|
-
message: `value is null`,
|
|
724
|
-
code: 1009,
|
|
725
|
-
status: "null",
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
return this;
|
|
730
|
-
}
|
|
731
|
-
toBeNullOrUndefined() {
|
|
732
|
-
this._expected = true;
|
|
733
|
-
|
|
734
|
-
if (this.value == null) ; else {
|
|
735
|
-
throw new TestException({
|
|
736
|
-
message: `value is not null/undefined`,
|
|
737
|
-
code: 1010,
|
|
738
|
-
status: "not-null-or-undefined",
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
return this;
|
|
743
|
-
}
|
|
744
|
-
notToBeNullOrUndefined() {
|
|
745
|
-
this._expected = true;
|
|
746
|
-
|
|
747
|
-
if (this.value == null) {
|
|
748
|
-
throw new TestException({
|
|
749
|
-
message: `value is null/undefined`,
|
|
750
|
-
code: 1011,
|
|
751
|
-
status: "null-or-undefined",
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
return this;
|
|
756
|
-
}
|
|
757
|
-
toBeEmptyArray() {
|
|
758
|
-
this._expected = true;
|
|
759
|
-
|
|
760
|
-
if (base.isSomeArray(this.value)) {
|
|
761
|
-
throw new TestException({
|
|
762
|
-
message: `${this.value} is some array`,
|
|
763
|
-
code: 1059,
|
|
764
|
-
status: "to-be-empty-array",
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
return this;
|
|
769
|
-
}
|
|
770
|
-
toBeValid(fnValidation) {
|
|
771
|
-
this._expected = true;
|
|
772
|
-
|
|
773
|
-
if (!base.isFunction(fnValidation)) {
|
|
774
|
-
throw new TestException({
|
|
775
|
-
message: `fnValidation is not function`,
|
|
776
|
-
code: 1064,
|
|
777
|
-
status: "to-be-valid",
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
if (!fnValidation(this.value)) {
|
|
781
|
-
throw new TestException({
|
|
782
|
-
message: `${this.value} is not valid`,
|
|
783
|
-
code: 1065,
|
|
784
|
-
status: "to-be-valid",
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
return this;
|
|
789
|
-
}
|
|
790
|
-
notToBeValid(fnValidation) {
|
|
791
|
-
this._expected = true;
|
|
792
|
-
|
|
793
|
-
if (!base.isFunction(fnValidation)) {
|
|
794
|
-
throw new TestException({
|
|
795
|
-
message: `fnValidation is not function`,
|
|
796
|
-
code: 1066,
|
|
797
|
-
status: "not-to-be-valid",
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
if (fnValidation(this.value)) {
|
|
801
|
-
throw new TestException({
|
|
802
|
-
message: `${this.value} is valid`,
|
|
803
|
-
code: 1067,
|
|
804
|
-
status: "not-to-be-valid",
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
return this;
|
|
809
|
-
}
|
|
810
|
-
toThrow(ex, shape = false, strict = false) {
|
|
811
|
-
this._expected = true;
|
|
812
|
-
|
|
813
|
-
if (!base.isFunction(this.value)) {
|
|
814
|
-
throw new TestException({
|
|
815
|
-
message: `given argument is not a function.`,
|
|
816
|
-
code: 1012,
|
|
817
|
-
status: "not-func",
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
let ok = false;
|
|
822
|
-
|
|
823
|
-
try {
|
|
824
|
-
this.value();
|
|
825
|
-
|
|
826
|
-
ok = true;
|
|
827
|
-
} catch (e) {
|
|
828
|
-
if (ex !== undefined) {
|
|
829
|
-
if (base.isPrimitive(ex)) {
|
|
830
|
-
if (e !== ex) {
|
|
831
|
-
throw new TestException({
|
|
832
|
-
message: `given function threw incorrect error.`,
|
|
833
|
-
code: 1018,
|
|
834
|
-
status: "incorrect-throw-error",
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
|
-
} else if (base.isFunction(ex)) {
|
|
838
|
-
if (!(e instanceof ex)) {
|
|
839
|
-
throw new TestException({
|
|
840
|
-
message: `given function threw incorrect instance.`,
|
|
841
|
-
code: 1019,
|
|
842
|
-
status: "incorrect-throw-instance",
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
} else if (base.isObject(ex)) {
|
|
846
|
-
if (shape) {
|
|
847
|
-
if (!base.equals(e, ex, strict)) {
|
|
848
|
-
throw new TestException({
|
|
849
|
-
message: `given function threw incorrect object shape.`,
|
|
850
|
-
code: 1020,
|
|
851
|
-
status: "incorrect-throw-shape",
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
} else {
|
|
855
|
-
if (e !== ex) {
|
|
856
|
-
throw new TestException({
|
|
857
|
-
message: `given function threw incorrect object.`,
|
|
858
|
-
code: 1021,
|
|
859
|
-
status: "incorrect-throw-object",
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
} else {
|
|
864
|
-
if (e !== ex) {
|
|
865
|
-
throw new TestException({
|
|
866
|
-
message: `given function threw incorrect value.`,
|
|
867
|
-
code: 1022,
|
|
868
|
-
status: "incorrect-throw-value",
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
} else {
|
|
873
|
-
ok = false;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
if (ok) {
|
|
878
|
-
throw new TestException({
|
|
879
|
-
message: `given function ran without throwing any errors.`,
|
|
880
|
-
code: 1013,
|
|
881
|
-
status: "ran-to-completion",
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
return this;
|
|
886
|
-
}
|
|
887
|
-
notToThrow(ex, shape = false, strict = false) {
|
|
888
|
-
this._expected = true;
|
|
889
|
-
|
|
890
|
-
if (!base.isFunction(this.value)) {
|
|
891
|
-
throw new TestException({
|
|
892
|
-
message: `given argument is not a function.`,
|
|
893
|
-
code: 1012,
|
|
894
|
-
status: "not-func",
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
let ok = true;
|
|
899
|
-
let error;
|
|
900
|
-
|
|
901
|
-
try {
|
|
902
|
-
this.value();
|
|
903
|
-
|
|
904
|
-
ok = false;
|
|
905
|
-
} catch (e) {
|
|
906
|
-
error = e;
|
|
907
|
-
|
|
908
|
-
if (ex !== undefined) {
|
|
909
|
-
if (base.isPrimitive(ex)) {
|
|
910
|
-
if (e === ex) {
|
|
911
|
-
throw new TestException({
|
|
912
|
-
message: `given function threw incorrect error.`,
|
|
913
|
-
code: 1018,
|
|
914
|
-
status: "incorrect-throw-error",
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
} else if (base.isFunction(ex)) {
|
|
918
|
-
if (e instanceof ex) {
|
|
919
|
-
throw new TestException({
|
|
920
|
-
message: `given function threw incorrect instance.`,
|
|
921
|
-
code: 1019,
|
|
922
|
-
status: "incorrect-throw-instance",
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
} else if (base.isObject(ex)) {
|
|
926
|
-
if (shape) {
|
|
927
|
-
if (base.equals(e, ex, strict)) {
|
|
928
|
-
throw new TestException({
|
|
929
|
-
message: `given function threw incorrect object shape.`,
|
|
930
|
-
code: 1020,
|
|
931
|
-
status: "incorrect-throw-shape",
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
} else {
|
|
935
|
-
if (e === ex) {
|
|
936
|
-
throw new TestException({
|
|
937
|
-
message: `given function threw incorrect object.`,
|
|
938
|
-
code: 1021,
|
|
939
|
-
status: "incorrect-throw-object",
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
} else {
|
|
944
|
-
if (e === ex) {
|
|
945
|
-
throw new TestException({
|
|
946
|
-
message: `given function threw incorrect value.`,
|
|
947
|
-
code: 1022,
|
|
948
|
-
status: "incorrect-throw-value",
|
|
949
|
-
});
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
} else {
|
|
953
|
-
ok = true;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
if (ok) {
|
|
958
|
-
throw new TestException({
|
|
959
|
-
message: `given function threw an error.`,
|
|
960
|
-
code: 1014,
|
|
961
|
-
status: "ran-to-error",
|
|
962
|
-
innerException: error,
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
return this;
|
|
967
|
-
}
|
|
968
|
-
async toThrowAsync(ex, shape = false, strict = false) {
|
|
969
|
-
this._expected = true;
|
|
970
|
-
|
|
971
|
-
if (!base.isFunction(this.value)) {
|
|
972
|
-
throw new TestException({
|
|
973
|
-
message: `given argument is not a function.`,
|
|
974
|
-
code: 1012,
|
|
975
|
-
status: "not-func",
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
let ok = false;
|
|
980
|
-
|
|
981
|
-
try {
|
|
982
|
-
await this.value();
|
|
983
|
-
|
|
984
|
-
ok = true;
|
|
985
|
-
} catch (e) {
|
|
986
|
-
if (ex !== undefined) {
|
|
987
|
-
if (base.isPrimitive(ex)) {
|
|
988
|
-
if (e !== ex) {
|
|
989
|
-
throw new TestException({
|
|
990
|
-
message: `given function threw incorrect error.`,
|
|
991
|
-
code: 1018,
|
|
992
|
-
status: "incorrect-throw-error",
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
} else if (base.isFunction(ex)) {
|
|
996
|
-
if (!(e instanceof ex)) {
|
|
997
|
-
throw new TestException({
|
|
998
|
-
message: `given function threw incorrect instance.`,
|
|
999
|
-
code: 1019,
|
|
1000
|
-
status: "incorrect-throw-instance",
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
|
-
} else if (base.isObject(ex)) {
|
|
1004
|
-
if (shape) {
|
|
1005
|
-
if (!base.equals(e, ex, strict)) {
|
|
1006
|
-
throw new TestException({
|
|
1007
|
-
message: `given function threw incorrect object shape.`,
|
|
1008
|
-
code: 1020,
|
|
1009
|
-
status: "incorrect-throw-shape",
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
} else {
|
|
1013
|
-
if (e !== ex) {
|
|
1014
|
-
throw new TestException({
|
|
1015
|
-
message: `given function threw incorrect object.`,
|
|
1016
|
-
code: 1021,
|
|
1017
|
-
status: "incorrect-throw-object",
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
} else {
|
|
1022
|
-
if (e !== ex) {
|
|
1023
|
-
throw new TestException({
|
|
1024
|
-
message: `given function threw incorrect value.`,
|
|
1025
|
-
code: 1022,
|
|
1026
|
-
status: "incorrect-throw-value",
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
} else {
|
|
1031
|
-
ok = false;
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
if (ok) {
|
|
1036
|
-
throw new TestException({
|
|
1037
|
-
message: `given function ran without throwing any errors.`,
|
|
1038
|
-
code: 1013,
|
|
1039
|
-
status: "ran-to-completion",
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
return this;
|
|
1044
|
-
}
|
|
1045
|
-
async notToThrowAsync(ex, shape = false, strict = false) {
|
|
1046
|
-
this._expected = true;
|
|
1047
|
-
|
|
1048
|
-
if (!base.isFunction(this.value)) {
|
|
1049
|
-
throw new TestException({
|
|
1050
|
-
message: `given argument is not a function.`,
|
|
1051
|
-
code: 1012,
|
|
1052
|
-
status: "not-func",
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
let ok = true;
|
|
1057
|
-
let error;
|
|
1058
|
-
|
|
1059
|
-
try {
|
|
1060
|
-
await this.value();
|
|
1061
|
-
|
|
1062
|
-
ok = false;
|
|
1063
|
-
} catch (e) {
|
|
1064
|
-
error = e;
|
|
1065
|
-
|
|
1066
|
-
if (ex !== undefined) {
|
|
1067
|
-
if (base.isPrimitive(ex)) {
|
|
1068
|
-
if (e === ex) {
|
|
1069
|
-
throw new TestException({
|
|
1070
|
-
message: `given function threw incorrect error.`,
|
|
1071
|
-
code: 1018,
|
|
1072
|
-
status: "incorrect-throw-error",
|
|
1073
|
-
});
|
|
1074
|
-
}
|
|
1075
|
-
} else if (base.isFunction(ex)) {
|
|
1076
|
-
if (e instanceof ex) {
|
|
1077
|
-
throw new TestException({
|
|
1078
|
-
message: `given function threw incorrect instance.`,
|
|
1079
|
-
code: 1019,
|
|
1080
|
-
status: "incorrect-throw-instance",
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
} else if (base.isObject(ex)) {
|
|
1084
|
-
if (shape) {
|
|
1085
|
-
if (base.equals(e, ex, strict)) {
|
|
1086
|
-
throw new TestException({
|
|
1087
|
-
message: `given function threw incorrect object shape.`,
|
|
1088
|
-
code: 1020,
|
|
1089
|
-
status: "incorrect-throw-shape",
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
} else {
|
|
1093
|
-
if (e === ex) {
|
|
1094
|
-
throw new TestException({
|
|
1095
|
-
message: `given function threw incorrect object.`,
|
|
1096
|
-
code: 1021,
|
|
1097
|
-
status: "incorrect-throw-object",
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
} else {
|
|
1102
|
-
if (e === ex) {
|
|
1103
|
-
throw new TestException({
|
|
1104
|
-
message: `given function threw incorrect value.`,
|
|
1105
|
-
code: 1022,
|
|
1106
|
-
status: "incorrect-throw-value",
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
} else {
|
|
1111
|
-
ok = true;
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
if (ok) {
|
|
1116
|
-
throw new TestException({
|
|
1117
|
-
message: `given function threw an error.`,
|
|
1118
|
-
code: 1014,
|
|
1119
|
-
status: "ran-to-error",
|
|
1120
|
-
innerException: error,
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
return this;
|
|
1125
|
-
}
|
|
1126
|
-
toBeTruthy() {
|
|
1127
|
-
this._expected = true;
|
|
1128
|
-
|
|
1129
|
-
if (this.value) ; else {
|
|
1130
|
-
throw new TestException({
|
|
1131
|
-
message: `${this.value} is not truthy`,
|
|
1132
|
-
code: 1015,
|
|
1133
|
-
status: "not-truthy",
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
return this;
|
|
1138
|
-
}
|
|
1139
|
-
toBeTrue() {
|
|
1140
|
-
return this.toBeTruthy();
|
|
1141
|
-
}
|
|
1142
|
-
toBeFalsy() {
|
|
1143
|
-
this._expected = true;
|
|
1144
|
-
|
|
1145
|
-
if (!this.value) ; else {
|
|
1146
|
-
throw new TestException({
|
|
1147
|
-
message: `${this.value} is not falsy`,
|
|
1148
|
-
code: 1016,
|
|
1149
|
-
status: "not-falsy",
|
|
1150
|
-
});
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
return this;
|
|
1154
|
-
}
|
|
1155
|
-
toBeFalse() {
|
|
1156
|
-
return this.toBeFalsy();
|
|
1157
|
-
}
|
|
1158
|
-
toBeNaN() {
|
|
1159
|
-
this._expected = true;
|
|
1160
|
-
|
|
1161
|
-
if (isNaN(this.value)) ; else {
|
|
1162
|
-
throw new TestException({
|
|
1163
|
-
message: `${this.value} is not NaN`,
|
|
1164
|
-
code: 1017,
|
|
1165
|
-
status: "not-nan",
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
return this;
|
|
1170
|
-
}
|
|
1171
|
-
notToBeNaN() {
|
|
1172
|
-
this._expected = true;
|
|
1173
|
-
|
|
1174
|
-
if (!isNaN(this.value)) ; else {
|
|
1175
|
-
throw new TestException({
|
|
1176
|
-
message: `${this.value} is NaN`,
|
|
1177
|
-
code: 1023,
|
|
1178
|
-
status: "is-nan",
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
return this;
|
|
1183
|
-
}
|
|
8
|
+
function _arrayLikeToArray(r, a) {
|
|
9
|
+
(null == a || a > r.length) && (a = r.length);
|
|
10
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
11
|
+
return n;
|
|
1184
12
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
}
|
|
1266
|
-
|
|
13
|
+
function _arrayWithoutHoles(r) {
|
|
14
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
15
|
+
}
|
|
16
|
+
function _assertThisInitialized(e) {
|
|
17
|
+
if (undefined === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
18
|
+
return e;
|
|
19
|
+
}
|
|
20
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
21
|
+
try {
|
|
22
|
+
var i = n[a](c),
|
|
23
|
+
u = i.value;
|
|
24
|
+
} catch (n) {
|
|
25
|
+
return void e(n);
|
|
26
|
+
}
|
|
27
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
28
|
+
}
|
|
29
|
+
function _asyncToGenerator(n) {
|
|
30
|
+
return function () {
|
|
31
|
+
var t = this,
|
|
32
|
+
e = arguments;
|
|
33
|
+
return new Promise(function (r, o) {
|
|
34
|
+
var a = n.apply(t, e);
|
|
35
|
+
function _next(n) {
|
|
36
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
37
|
+
}
|
|
38
|
+
function _throw(n) {
|
|
39
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
40
|
+
}
|
|
41
|
+
_next(undefined);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function _callSuper(t, o, e) {
|
|
46
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
47
|
+
}
|
|
48
|
+
function _classCallCheck(a, n) {
|
|
49
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
50
|
+
}
|
|
51
|
+
function _defineProperties(e, r) {
|
|
52
|
+
for (var t = 0; t < r.length; t++) {
|
|
53
|
+
var o = r[t];
|
|
54
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function _createClass(e, r, t) {
|
|
58
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
59
|
+
writable: false
|
|
60
|
+
}), e;
|
|
61
|
+
}
|
|
62
|
+
function _createForOfIteratorHelper(r, e) {
|
|
63
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
64
|
+
if (!t) {
|
|
65
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
66
|
+
t && (r = t);
|
|
67
|
+
var n = 0,
|
|
68
|
+
F = function () {};
|
|
69
|
+
return {
|
|
70
|
+
s: F,
|
|
71
|
+
n: function () {
|
|
72
|
+
return n >= r.length ? {
|
|
73
|
+
done: true
|
|
74
|
+
} : {
|
|
75
|
+
done: false,
|
|
76
|
+
value: r[n++]
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
e: function (r) {
|
|
80
|
+
throw r;
|
|
81
|
+
},
|
|
82
|
+
f: F
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
86
|
+
}
|
|
87
|
+
var o,
|
|
88
|
+
a = true,
|
|
89
|
+
u = false;
|
|
90
|
+
return {
|
|
91
|
+
s: function () {
|
|
92
|
+
t = t.call(r);
|
|
93
|
+
},
|
|
94
|
+
n: function () {
|
|
95
|
+
var r = t.next();
|
|
96
|
+
return a = r.done, r;
|
|
97
|
+
},
|
|
98
|
+
e: function (r) {
|
|
99
|
+
u = true, o = r;
|
|
100
|
+
},
|
|
101
|
+
f: function () {
|
|
102
|
+
try {
|
|
103
|
+
a || null == t.return || t.return();
|
|
104
|
+
} finally {
|
|
105
|
+
if (u) throw o;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function _getPrototypeOf(t) {
|
|
111
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
112
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
113
|
+
}, _getPrototypeOf(t);
|
|
114
|
+
}
|
|
115
|
+
function _inherits(t, e) {
|
|
116
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
117
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
118
|
+
constructor: {
|
|
119
|
+
value: t,
|
|
120
|
+
writable: true,
|
|
121
|
+
configurable: true
|
|
122
|
+
}
|
|
123
|
+
}), Object.defineProperty(t, "prototype", {
|
|
124
|
+
writable: false
|
|
125
|
+
}), e && _setPrototypeOf(t, e);
|
|
126
|
+
}
|
|
127
|
+
function _isNativeReflectConstruct() {
|
|
128
|
+
try {
|
|
129
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
130
|
+
} catch (t) {}
|
|
131
|
+
return (_isNativeReflectConstruct = function () {
|
|
132
|
+
return !!t;
|
|
133
|
+
})();
|
|
1267
134
|
}
|
|
135
|
+
function _iterableToArray(r) {
|
|
136
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
137
|
+
}
|
|
138
|
+
function _nonIterableSpread() {
|
|
139
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
140
|
+
}
|
|
141
|
+
function _possibleConstructorReturn(t, e) {
|
|
142
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
143
|
+
if (undefined !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
144
|
+
return _assertThisInitialized(t);
|
|
145
|
+
}
|
|
146
|
+
function _regeneratorRuntime() {
|
|
147
|
+
_regeneratorRuntime = function () {
|
|
148
|
+
return e;
|
|
149
|
+
};
|
|
150
|
+
var t,
|
|
151
|
+
e = {},
|
|
152
|
+
r = Object.prototype,
|
|
153
|
+
n = r.hasOwnProperty,
|
|
154
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
155
|
+
t[e] = r.value;
|
|
156
|
+
},
|
|
157
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
158
|
+
a = i.iterator || "@@iterator",
|
|
159
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
160
|
+
u = i.toStringTag || "@@toStringTag";
|
|
161
|
+
function define(t, e, r) {
|
|
162
|
+
return Object.defineProperty(t, e, {
|
|
163
|
+
value: r,
|
|
164
|
+
enumerable: true,
|
|
165
|
+
configurable: true,
|
|
166
|
+
writable: true
|
|
167
|
+
}), t[e];
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
define({}, "");
|
|
171
|
+
} catch (t) {
|
|
172
|
+
define = function (t, e, r) {
|
|
173
|
+
return t[e] = r;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function wrap(t, e, r, n) {
|
|
177
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
178
|
+
a = Object.create(i.prototype),
|
|
179
|
+
c = new Context(n || []);
|
|
180
|
+
return o(a, "_invoke", {
|
|
181
|
+
value: makeInvokeMethod(t, r, c)
|
|
182
|
+
}), a;
|
|
183
|
+
}
|
|
184
|
+
function tryCatch(t, e, r) {
|
|
185
|
+
try {
|
|
186
|
+
return {
|
|
187
|
+
type: "normal",
|
|
188
|
+
arg: t.call(e, r)
|
|
189
|
+
};
|
|
190
|
+
} catch (t) {
|
|
191
|
+
return {
|
|
192
|
+
type: "throw",
|
|
193
|
+
arg: t
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
e.wrap = wrap;
|
|
198
|
+
var h = "suspendedStart",
|
|
199
|
+
l = "suspendedYield",
|
|
200
|
+
f = "executing",
|
|
201
|
+
s = "completed",
|
|
202
|
+
y = {};
|
|
203
|
+
function Generator() {}
|
|
204
|
+
function GeneratorFunction() {}
|
|
205
|
+
function GeneratorFunctionPrototype() {}
|
|
206
|
+
var p = {};
|
|
207
|
+
define(p, a, function () {
|
|
208
|
+
return this;
|
|
209
|
+
});
|
|
210
|
+
var d = Object.getPrototypeOf,
|
|
211
|
+
v = d && d(d(values([])));
|
|
212
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
213
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
214
|
+
function defineIteratorMethods(t) {
|
|
215
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
216
|
+
define(t, e, function (t) {
|
|
217
|
+
return this._invoke(e, t);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function AsyncIterator(t, e) {
|
|
222
|
+
function invoke(r, o, i, a) {
|
|
223
|
+
var c = tryCatch(t[r], t, o);
|
|
224
|
+
if ("throw" !== c.type) {
|
|
225
|
+
var u = c.arg,
|
|
226
|
+
h = u.value;
|
|
227
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
228
|
+
invoke("next", t, i, a);
|
|
229
|
+
}, function (t) {
|
|
230
|
+
invoke("throw", t, i, a);
|
|
231
|
+
}) : e.resolve(h).then(function (t) {
|
|
232
|
+
u.value = t, i(u);
|
|
233
|
+
}, function (t) {
|
|
234
|
+
return invoke("throw", t, i, a);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
a(c.arg);
|
|
238
|
+
}
|
|
239
|
+
var r;
|
|
240
|
+
o(this, "_invoke", {
|
|
241
|
+
value: function (t, n) {
|
|
242
|
+
function callInvokeWithMethodAndArg() {
|
|
243
|
+
return new e(function (e, r) {
|
|
244
|
+
invoke(t, n, e, r);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function makeInvokeMethod(e, r, n) {
|
|
252
|
+
var o = h;
|
|
253
|
+
return function (i, a) {
|
|
254
|
+
if (o === f) throw Error("Generator is already running");
|
|
255
|
+
if (o === s) {
|
|
256
|
+
if ("throw" === i) throw a;
|
|
257
|
+
return {
|
|
258
|
+
value: t,
|
|
259
|
+
done: true
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
for (n.method = i, n.arg = a;;) {
|
|
263
|
+
var c = n.delegate;
|
|
264
|
+
if (c) {
|
|
265
|
+
var u = maybeInvokeDelegate(c, n);
|
|
266
|
+
if (u) {
|
|
267
|
+
if (u === y) continue;
|
|
268
|
+
return u;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
272
|
+
if (o === h) throw o = s, n.arg;
|
|
273
|
+
n.dispatchException(n.arg);
|
|
274
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
275
|
+
o = f;
|
|
276
|
+
var p = tryCatch(e, r, n);
|
|
277
|
+
if ("normal" === p.type) {
|
|
278
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
279
|
+
return {
|
|
280
|
+
value: p.arg,
|
|
281
|
+
done: n.done
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function maybeInvokeDelegate(e, r) {
|
|
289
|
+
var n = r.method,
|
|
290
|
+
o = e.iterator[n];
|
|
291
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
292
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
293
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
294
|
+
var a = i.arg;
|
|
295
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
296
|
+
}
|
|
297
|
+
function pushTryEntry(t) {
|
|
298
|
+
var e = {
|
|
299
|
+
tryLoc: t[0]
|
|
300
|
+
};
|
|
301
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
302
|
+
}
|
|
303
|
+
function resetTryEntry(t) {
|
|
304
|
+
var e = t.completion || {};
|
|
305
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
306
|
+
}
|
|
307
|
+
function Context(t) {
|
|
308
|
+
this.tryEntries = [{
|
|
309
|
+
tryLoc: "root"
|
|
310
|
+
}], t.forEach(pushTryEntry, this), this.reset(true);
|
|
311
|
+
}
|
|
312
|
+
function values(e) {
|
|
313
|
+
if (e || "" === e) {
|
|
314
|
+
var r = e[a];
|
|
315
|
+
if (r) return r.call(e);
|
|
316
|
+
if ("function" == typeof e.next) return e;
|
|
317
|
+
if (!isNaN(e.length)) {
|
|
318
|
+
var o = -1,
|
|
319
|
+
i = function next() {
|
|
320
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
|
|
321
|
+
return next.value = t, next.done = true, next;
|
|
322
|
+
};
|
|
323
|
+
return i.next = i;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
327
|
+
}
|
|
328
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
329
|
+
value: GeneratorFunctionPrototype,
|
|
330
|
+
configurable: true
|
|
331
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
332
|
+
value: GeneratorFunction,
|
|
333
|
+
configurable: true
|
|
334
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
335
|
+
var e = "function" == typeof t && t.constructor;
|
|
336
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
337
|
+
}, e.mark = function (t) {
|
|
338
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
339
|
+
}, e.awrap = function (t) {
|
|
340
|
+
return {
|
|
341
|
+
__await: t
|
|
342
|
+
};
|
|
343
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
344
|
+
return this;
|
|
345
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
346
|
+
undefined === i && (i = Promise);
|
|
347
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
348
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
349
|
+
return t.done ? t.value : a.next();
|
|
350
|
+
});
|
|
351
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
352
|
+
return this;
|
|
353
|
+
}), define(g, "toString", function () {
|
|
354
|
+
return "[object Generator]";
|
|
355
|
+
}), e.keys = function (t) {
|
|
356
|
+
var e = Object(t),
|
|
357
|
+
r = [];
|
|
358
|
+
for (var n in e) r.push(n);
|
|
359
|
+
return r.reverse(), function next() {
|
|
360
|
+
for (; r.length;) {
|
|
361
|
+
var t = r.pop();
|
|
362
|
+
if (t in e) return next.value = t, next.done = false, next;
|
|
363
|
+
}
|
|
364
|
+
return next.done = true, next;
|
|
365
|
+
};
|
|
366
|
+
}, e.values = values, Context.prototype = {
|
|
367
|
+
constructor: Context,
|
|
368
|
+
reset: function (e) {
|
|
369
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
370
|
+
},
|
|
371
|
+
stop: function () {
|
|
372
|
+
this.done = true;
|
|
373
|
+
var t = this.tryEntries[0].completion;
|
|
374
|
+
if ("throw" === t.type) throw t.arg;
|
|
375
|
+
return this.rval;
|
|
376
|
+
},
|
|
377
|
+
dispatchException: function (e) {
|
|
378
|
+
if (this.done) throw e;
|
|
379
|
+
var r = this;
|
|
380
|
+
function handle(n, o) {
|
|
381
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
382
|
+
}
|
|
383
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
384
|
+
var i = this.tryEntries[o],
|
|
385
|
+
a = i.completion;
|
|
386
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
387
|
+
if (i.tryLoc <= this.prev) {
|
|
388
|
+
var c = n.call(i, "catchLoc"),
|
|
389
|
+
u = n.call(i, "finallyLoc");
|
|
390
|
+
if (c && u) {
|
|
391
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
|
|
392
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
393
|
+
} else if (c) {
|
|
394
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
|
|
395
|
+
} else {
|
|
396
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
397
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
abrupt: function (t, e) {
|
|
403
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
404
|
+
var o = this.tryEntries[r];
|
|
405
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
406
|
+
var i = o;
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
411
|
+
var a = i ? i.completion : {};
|
|
412
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
413
|
+
},
|
|
414
|
+
complete: function (t, e) {
|
|
415
|
+
if ("throw" === t.type) throw t.arg;
|
|
416
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
417
|
+
},
|
|
418
|
+
finish: function (t) {
|
|
419
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
420
|
+
var r = this.tryEntries[e];
|
|
421
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
catch: function (t) {
|
|
425
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
426
|
+
var r = this.tryEntries[e];
|
|
427
|
+
if (r.tryLoc === t) {
|
|
428
|
+
var n = r.completion;
|
|
429
|
+
if ("throw" === n.type) {
|
|
430
|
+
var o = n.arg;
|
|
431
|
+
resetTryEntry(r);
|
|
432
|
+
}
|
|
433
|
+
return o;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
throw Error("illegal catch attempt");
|
|
437
|
+
},
|
|
438
|
+
delegateYield: function (e, r, n) {
|
|
439
|
+
return this.delegate = {
|
|
440
|
+
iterator: values(e),
|
|
441
|
+
resultName: r,
|
|
442
|
+
nextLoc: n
|
|
443
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
444
|
+
}
|
|
445
|
+
}, e;
|
|
446
|
+
}
|
|
447
|
+
function _setPrototypeOf(t, e) {
|
|
448
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
449
|
+
return t.__proto__ = e, t;
|
|
450
|
+
}, _setPrototypeOf(t, e);
|
|
451
|
+
}
|
|
452
|
+
function _toConsumableArray(r) {
|
|
453
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
454
|
+
}
|
|
455
|
+
function _toPrimitive(t, r) {
|
|
456
|
+
if ("object" != typeof t || !t) return t;
|
|
457
|
+
var e = t[Symbol.toPrimitive];
|
|
458
|
+
if (undefined !== e) {
|
|
459
|
+
var i = e.call(t, r);
|
|
460
|
+
if ("object" != typeof i) return i;
|
|
461
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
462
|
+
}
|
|
463
|
+
return (String )(t);
|
|
464
|
+
}
|
|
465
|
+
function _toPropertyKey(t) {
|
|
466
|
+
var i = _toPrimitive(t, "string");
|
|
467
|
+
return "symbol" == typeof i ? i : i + "";
|
|
468
|
+
}
|
|
469
|
+
function _typeof(o) {
|
|
470
|
+
"@babel/helpers - typeof";
|
|
1268
471
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
}
|
|
1282
|
-
_init() {
|
|
1283
|
-
this._passed = 0;
|
|
1284
|
-
this._failed = 0;
|
|
1285
|
-
this._faulted = 0;
|
|
1286
|
-
this._unknown = 0;
|
|
1287
|
-
this._results = [];
|
|
1288
|
-
this._errors = [];
|
|
1289
|
-
}
|
|
1290
|
-
async _runSingle(test, onProgress, i) {
|
|
1291
|
-
if (base.isFunction(onProgress)) {
|
|
1292
|
-
try {
|
|
1293
|
-
onProgress({ source: this, test, index: i });
|
|
1294
|
-
} catch (ex) {
|
|
1295
|
-
this._errors.push({
|
|
1296
|
-
index: i,
|
|
1297
|
-
test: test.name,
|
|
1298
|
-
err: new TestException({
|
|
1299
|
-
message: `onProgress failed for test '${test.name} at index ${i}'.`,
|
|
1300
|
-
code: 1500,
|
|
1301
|
-
status: "progress-failed",
|
|
1302
|
-
innerException: ex,
|
|
1303
|
-
}),
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
if (!(test instanceof Test)) {
|
|
1308
|
-
this._unknown++;
|
|
1309
|
-
|
|
1310
|
-
this._errors.push({
|
|
1311
|
-
index: i,
|
|
1312
|
-
err: new TestException({
|
|
1313
|
-
message: `Given test is not an instance of '@locustjs/test:Test' class.`,
|
|
1314
|
-
code: 1504,
|
|
1315
|
-
status: "invalid-test",
|
|
1316
|
-
}),
|
|
1317
|
-
});
|
|
1318
|
-
} else {
|
|
1319
|
-
const tr = await test.run();
|
|
1320
|
-
this._results.push(tr);
|
|
1321
|
-
|
|
1322
|
-
if (base.isObject(tr.err)) {
|
|
1323
|
-
if (!tr.expected) {
|
|
1324
|
-
this._faulted++;
|
|
1325
|
-
} else {
|
|
1326
|
-
this._failed++;
|
|
1327
|
-
}
|
|
1328
|
-
} else if (!tr.expected) {
|
|
1329
|
-
this._unknown++;
|
|
1330
|
-
} else if (tr.success) {
|
|
1331
|
-
this._passed++;
|
|
1332
|
-
} else {
|
|
1333
|
-
this._failed++;
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
get result() {
|
|
1338
|
-
return {
|
|
1339
|
-
passed: this._passed,
|
|
1340
|
-
failed: this._failed,
|
|
1341
|
-
faulted: this._faulted,
|
|
1342
|
-
results: this._results,
|
|
1343
|
-
errors: this._errors,
|
|
1344
|
-
};
|
|
1345
|
-
}
|
|
1346
|
-
run(tests, onProgress) {
|
|
1347
|
-
this._init();
|
|
1348
|
-
|
|
1349
|
-
return new Promise((res) => {
|
|
1350
|
-
if (tests) {
|
|
1351
|
-
if (tests instanceof Test) {
|
|
1352
|
-
tests = [tests];
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
if (base.isArray(tests)) {
|
|
1356
|
-
const _tests = tests
|
|
1357
|
-
.map((test) => {
|
|
1358
|
-
let _test = test;
|
|
1359
|
-
|
|
1360
|
-
if (base.isArray(test)) {
|
|
1361
|
-
if (test.length == 2) {
|
|
1362
|
-
_test = new Test(test[0], test[1]);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
return _test;
|
|
1367
|
-
})
|
|
1368
|
-
.map((test, i) => this._runSingle(test, onProgress, i));
|
|
1369
|
-
|
|
1370
|
-
Promise.all(_tests)
|
|
1371
|
-
.then((_) => res(this.result))
|
|
1372
|
-
.catch((ex) => {
|
|
1373
|
-
this._errors.push({
|
|
1374
|
-
err: new TestException({
|
|
1375
|
-
message: `not all tests succeeded. check errors.`,
|
|
1376
|
-
code: 1503,
|
|
1377
|
-
status: "partial-finished",
|
|
1378
|
-
innerException: ex,
|
|
1379
|
-
}),
|
|
1380
|
-
});
|
|
1381
|
-
|
|
1382
|
-
res(this.result);
|
|
1383
|
-
});
|
|
1384
|
-
} else {
|
|
1385
|
-
this._errors.push({
|
|
1386
|
-
err: new TestException({
|
|
1387
|
-
message: `invalid tests. expected array or a single test.`,
|
|
1388
|
-
code: 1502,
|
|
1389
|
-
status: "invalid-tests",
|
|
1390
|
-
}),
|
|
1391
|
-
});
|
|
1392
|
-
|
|
1393
|
-
res(this.result);
|
|
1394
|
-
}
|
|
1395
|
-
} else {
|
|
1396
|
-
this._errors.push({
|
|
1397
|
-
err: new TestException({
|
|
1398
|
-
message: `no tests given to be ran.`,
|
|
1399
|
-
code: 1501,
|
|
1400
|
-
status: "no-tests",
|
|
1401
|
-
}),
|
|
1402
|
-
});
|
|
1403
|
-
|
|
1404
|
-
res(this.result);
|
|
1405
|
-
}
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
_getTime(time) {
|
|
1409
|
-
return `${time / 1000} sec`;
|
|
1410
|
-
}
|
|
1411
|
-
report(detailed) {
|
|
1412
|
-
let time = 0;
|
|
1413
|
-
|
|
1414
|
-
console.log("Finished.\n");
|
|
1415
|
-
|
|
1416
|
-
for (let i = 0; i < this._results.length; i++) {
|
|
1417
|
-
const testResult = this._results[i];
|
|
1418
|
-
const t = `(${this._getTime(testResult.time)})`;
|
|
1419
|
-
|
|
1420
|
-
if (detailed) {
|
|
1421
|
-
let message = "\n" + (i + 1) + ". ";
|
|
1422
|
-
let err = base.isObject(testResult.err)
|
|
1423
|
-
? testResult.err.toString().split("\n")
|
|
1424
|
-
: [];
|
|
1425
|
-
|
|
1426
|
-
err = err
|
|
1427
|
-
.map(
|
|
1428
|
-
(msg, i) =>
|
|
1429
|
-
`\t${
|
|
1430
|
-
i == err.length - 1
|
|
1431
|
-
? `${fgYellow}`
|
|
1432
|
-
: `${fgGray}error ${testResult.err.code}: `
|
|
1433
|
-
}${msg}${reset}`
|
|
1434
|
-
)
|
|
1435
|
-
.join("\n");
|
|
1436
|
-
|
|
1437
|
-
if (base.isObject(testResult.err)) {
|
|
1438
|
-
if (!testResult.expected) {
|
|
1439
|
-
message += `${bright}${fgWhite}${testResult.test}: ${fgYellow}faulted${reset} ${t}`;
|
|
1440
|
-
message += "\n";
|
|
1441
|
-
message += `${fgGray}${err} ${reset}`;
|
|
1442
|
-
} else {
|
|
1443
|
-
message += `${bright}${fgWhite}${testResult.test}: ${fgRed}failed${reset} ${t}`;
|
|
1444
|
-
message += "\n";
|
|
1445
|
-
message += `${fgGray}${err} ${reset}`;
|
|
1446
|
-
}
|
|
1447
|
-
} else if (!testResult.expected) {
|
|
1448
|
-
message += `${bright}${fgWhite}${testResult.test}: ${fgMagenta}expect not used${reset} ${t}`;
|
|
1449
|
-
|
|
1450
|
-
if (testResult.err) {
|
|
1451
|
-
message += "\n";
|
|
1452
|
-
message += `${fgGray}${err} ${reset}`;
|
|
1453
|
-
}
|
|
1454
|
-
} else if (testResult.success) {
|
|
1455
|
-
message += `${fgWhite}${testResult.test}: ${fgGreen}passed${reset} ${t}`;
|
|
1456
|
-
} else {
|
|
1457
|
-
message += `${bright}${fgWhite}${testResult.test}: ${fgRed}failed${reset} ${t}`;
|
|
1458
|
-
message += "\n";
|
|
1459
|
-
message += `${fgGray}${err} ${reset}`;
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
console.log(message);
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
time += testResult.time;
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
if (detailed && this._errors.length) {
|
|
1469
|
-
console.log("Errors:");
|
|
1470
|
-
|
|
1471
|
-
for (let error of this._errors) {
|
|
1472
|
-
if (error.index !== undefined) {
|
|
1473
|
-
console.log(
|
|
1474
|
-
`${error.index}. ${
|
|
1475
|
-
error.test
|
|
1476
|
-
}: ${error.err.innerException.toString()}`
|
|
1477
|
-
);
|
|
1478
|
-
} else {
|
|
1479
|
-
console.log(`${error.err.toString()}`);
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
const text =
|
|
1485
|
-
(detailed ? "\n" : "") +
|
|
1486
|
-
`${bright}Number of tests: ${reset}${this._results.length}` +
|
|
1487
|
-
"\n" +
|
|
1488
|
-
`${bright}Total Time: ${reset}${time / 1000} sec` +
|
|
1489
|
-
"\n\n" +
|
|
1490
|
-
(this._passed > 0
|
|
1491
|
-
? `${fgGreen} ${this._passed} test(s) passed${reset}`
|
|
1492
|
-
: `0 tests passed${reset}`) +
|
|
1493
|
-
", " +
|
|
1494
|
-
(this._failed > 0
|
|
1495
|
-
? `${fgRed}${this._failed} test(s) failed${reset}`
|
|
1496
|
-
: `0 tests failed${reset}`) +
|
|
1497
|
-
(this._faulted > 0
|
|
1498
|
-
? `, ${fgYellow}${this._faulted} test(s) faulted${reset}`
|
|
1499
|
-
: ``) +
|
|
1500
|
-
(this._unknown > 0
|
|
1501
|
-
? `, ${fgMagenta}${this._unknown} test(s) are unknown${reset}`
|
|
1502
|
-
: ``) +
|
|
1503
|
-
"\n";
|
|
1504
|
-
|
|
1505
|
-
console.log(text);
|
|
1506
|
-
}
|
|
1507
|
-
log(filename) {
|
|
1508
|
-
const content = JSON.stringify(
|
|
1509
|
-
{
|
|
1510
|
-
results: this._results,
|
|
1511
|
-
errors: this._errors,
|
|
1512
|
-
},
|
|
1513
|
-
null,
|
|
1514
|
-
"\t"
|
|
1515
|
-
);
|
|
1516
|
-
|
|
1517
|
-
if (filename == null) {
|
|
1518
|
-
const d = new Date();
|
|
1519
|
-
|
|
1520
|
-
const year = d.getFullYear().toString().padStart(4, "0");
|
|
1521
|
-
const month = (d.getMonth() + 1).toString().padStart(2, "0");
|
|
1522
|
-
const day = d.getDate().toString().padStart(2, "0");
|
|
1523
|
-
const hours = d.getHours().toString().padStart(2, "0");
|
|
1524
|
-
const minutes = d.getMinutes().toString().padStart(2, "0");
|
|
1525
|
-
const seconds = d.getSeconds().toString().padStart(2, "0");
|
|
1526
|
-
|
|
1527
|
-
filename = `test-${year}-${month}-${day}-${hours}${minutes}${seconds}.json`;
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
const filepath = path.join(process.cwd(), filename);
|
|
1531
|
-
|
|
1532
|
-
try {
|
|
1533
|
-
fs.writeFileSync(filepath, content);
|
|
1534
|
-
|
|
1535
|
-
console.log(`tests outcome wrote in ${filename}.`);
|
|
1536
|
-
} catch (ex) {
|
|
1537
|
-
console.log("writing tests' report failed.\n" + ex);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
async test(...tests) {
|
|
1541
|
-
const lastArg = tests[tests.length - 1];
|
|
1542
|
-
const detailed = tests.length && base.isBool(lastArg) ? lastArg : false;
|
|
1543
|
-
let _tests = [];
|
|
1544
|
-
|
|
1545
|
-
for (let i = 0; i < tests.length; i++) {
|
|
1546
|
-
const t = tests[i];
|
|
1547
|
-
|
|
1548
|
-
if (i != tests.length - 1 || !base.isBool(t)) {
|
|
1549
|
-
if (base.isIterable(t)) {
|
|
1550
|
-
_tests = [..._tests, ...t];
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
const result = await this.run(_tests);
|
|
1556
|
-
|
|
1557
|
-
this.report(detailed || result.failed > 0);
|
|
1558
|
-
|
|
1559
|
-
return { runner: this, result };
|
|
1560
|
-
}
|
|
1561
|
-
static start(...tests) {
|
|
1562
|
-
const tr = new TestRunner();
|
|
1563
|
-
|
|
1564
|
-
return tr.test(...tests);
|
|
1565
|
-
}
|
|
472
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
473
|
+
return typeof o;
|
|
474
|
+
} : function (o) {
|
|
475
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
476
|
+
}, _typeof(o);
|
|
477
|
+
}
|
|
478
|
+
function _unsupportedIterableToArray(r, a) {
|
|
479
|
+
if (r) {
|
|
480
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
481
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
482
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
|
|
483
|
+
}
|
|
1566
484
|
}
|
|
1567
485
|
|
|
486
|
+
var TestException = /*#__PURE__*/function (_Exception) {
|
|
487
|
+
function TestException() {
|
|
488
|
+
_classCallCheck(this, TestException);
|
|
489
|
+
return _callSuper(this, TestException, arguments);
|
|
490
|
+
}
|
|
491
|
+
_inherits(TestException, _Exception);
|
|
492
|
+
return _createClass(TestException);
|
|
493
|
+
}(exception.Exception);
|
|
494
|
+
|
|
495
|
+
var Expect = /*#__PURE__*/function () {
|
|
496
|
+
function Expect(value) {
|
|
497
|
+
_classCallCheck(this, Expect);
|
|
498
|
+
this.value = value;
|
|
499
|
+
this._expected = false;
|
|
500
|
+
}
|
|
501
|
+
return _createClass(Expect, [{
|
|
502
|
+
key: "expected",
|
|
503
|
+
get: function get() {
|
|
504
|
+
return this._expected;
|
|
505
|
+
}
|
|
506
|
+
}, {
|
|
507
|
+
key: "toBe",
|
|
508
|
+
value: function toBe(value) {
|
|
509
|
+
this._expected = true;
|
|
510
|
+
if (this.value === value) ; else {
|
|
511
|
+
throw new TestException({
|
|
512
|
+
message: "".concat(this.value, " is not equal to ").concat(value),
|
|
513
|
+
code: 1000,
|
|
514
|
+
status: "not-eq"
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
return this;
|
|
518
|
+
}
|
|
519
|
+
}, {
|
|
520
|
+
key: "notToBe",
|
|
521
|
+
value: function notToBe(value) {
|
|
522
|
+
this._expected = true;
|
|
523
|
+
if (this.value === value) {
|
|
524
|
+
throw new TestException({
|
|
525
|
+
message: "".concat(value, " is equal to ").concat(this.value),
|
|
526
|
+
code: 1005,
|
|
527
|
+
status: "eq"
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
return this;
|
|
531
|
+
}
|
|
532
|
+
}, {
|
|
533
|
+
key: "toBeGt",
|
|
534
|
+
value: function toBeGt(value) {
|
|
535
|
+
this._expected = true;
|
|
536
|
+
if (this.value <= value) {
|
|
537
|
+
throw new TestException({
|
|
538
|
+
message: "".concat(this.value, " is not greater than ").concat(value),
|
|
539
|
+
code: 1001,
|
|
540
|
+
status: "lte"
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
return this;
|
|
544
|
+
}
|
|
545
|
+
}, {
|
|
546
|
+
key: "toBeGreaterThan",
|
|
547
|
+
value: function toBeGreaterThan(value) {
|
|
548
|
+
return this.toBeGt(value);
|
|
549
|
+
}
|
|
550
|
+
}, {
|
|
551
|
+
key: "toBeGte",
|
|
552
|
+
value: function toBeGte(value) {
|
|
553
|
+
this._expected = true;
|
|
554
|
+
if (this.value < value) {
|
|
555
|
+
throw new TestException({
|
|
556
|
+
message: "".concat(this.value, " is not greater than or equal to ").concat(value),
|
|
557
|
+
code: 1002,
|
|
558
|
+
status: "lt"
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
return this;
|
|
562
|
+
}
|
|
563
|
+
}, {
|
|
564
|
+
key: "toBeGreaterThanOrEqualTo",
|
|
565
|
+
value: function toBeGreaterThanOrEqualTo(value) {
|
|
566
|
+
return this.toBeGte(value);
|
|
567
|
+
}
|
|
568
|
+
}, {
|
|
569
|
+
key: "toBeLt",
|
|
570
|
+
value: function toBeLt(value) {
|
|
571
|
+
this._expected = true;
|
|
572
|
+
if (this.value >= value) {
|
|
573
|
+
throw new TestException({
|
|
574
|
+
message: "".concat(this.value, " is not less than ").concat(value),
|
|
575
|
+
code: 1003,
|
|
576
|
+
status: "gte"
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
}, {
|
|
582
|
+
key: "toBeLowerThan",
|
|
583
|
+
value: function toBeLowerThan(value) {
|
|
584
|
+
return this.toBeLt(value);
|
|
585
|
+
}
|
|
586
|
+
}, {
|
|
587
|
+
key: "toBeLte",
|
|
588
|
+
value: function toBeLte(value) {
|
|
589
|
+
this._expected = true;
|
|
590
|
+
if (this.value > value) {
|
|
591
|
+
throw new TestException({
|
|
592
|
+
message: "".concat(this.value, " is not less than or equal to ").concat(value),
|
|
593
|
+
code: 1004,
|
|
594
|
+
status: "gt"
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
return this;
|
|
598
|
+
}
|
|
599
|
+
}, {
|
|
600
|
+
key: "toBeLowerThanOrEqualTo",
|
|
601
|
+
value: function toBeLowerThanOrEqualTo(value) {
|
|
602
|
+
return this.toBeLte(value);
|
|
603
|
+
}
|
|
604
|
+
}, {
|
|
605
|
+
key: "toBeBetween",
|
|
606
|
+
value: function toBeBetween(n, m) {
|
|
607
|
+
this._expected = true;
|
|
608
|
+
if (!(this.value >= n && this.value < m)) {
|
|
609
|
+
throw new TestException({
|
|
610
|
+
message: "".concat(this.value, " is not between ").concat(n, " and ").concat(m),
|
|
611
|
+
code: 1024,
|
|
612
|
+
status: "between"
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
return this;
|
|
616
|
+
}
|
|
617
|
+
}, {
|
|
618
|
+
key: "notToBeBetween",
|
|
619
|
+
value: function notToBeBetween(n, m) {
|
|
620
|
+
this._expected = true;
|
|
621
|
+
if (this.value >= n && this.value < m) {
|
|
622
|
+
throw new TestException({
|
|
623
|
+
message: "".concat(this.value, " is between ").concat(n, " and ").concat(m),
|
|
624
|
+
code: 1044,
|
|
625
|
+
status: "not-between"
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return this;
|
|
629
|
+
}
|
|
630
|
+
}, {
|
|
631
|
+
key: "toBeOfType",
|
|
632
|
+
value: function toBeOfType(type) {
|
|
633
|
+
this._expected = true;
|
|
634
|
+
if (_typeof(this.value) !== type) {
|
|
635
|
+
throw new TestException({
|
|
636
|
+
message: "".concat(this.value, " is not of type ").concat(type),
|
|
637
|
+
code: 1025,
|
|
638
|
+
status: "of-type"
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
return this;
|
|
642
|
+
}
|
|
643
|
+
}, {
|
|
644
|
+
key: "notToBeOfType",
|
|
645
|
+
value: function notToBeOfType(type) {
|
|
646
|
+
this._expected = true;
|
|
647
|
+
if (_typeof(this.value) === type) {
|
|
648
|
+
throw new TestException({
|
|
649
|
+
message: "".concat(this.value, " is of type ").concat(type),
|
|
650
|
+
code: 1045,
|
|
651
|
+
status: "not-oftype"
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
return this;
|
|
655
|
+
}
|
|
656
|
+
}, {
|
|
657
|
+
key: "toBeString",
|
|
658
|
+
value: function toBeString() {
|
|
659
|
+
this._expected = true;
|
|
660
|
+
if (!base.isString(this.value)) {
|
|
661
|
+
throw new TestException({
|
|
662
|
+
message: "".concat(this.value, " is not string"),
|
|
663
|
+
code: 1026,
|
|
664
|
+
status: "is-string"
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
return this;
|
|
668
|
+
}
|
|
669
|
+
}, {
|
|
670
|
+
key: "notToBeString",
|
|
671
|
+
value: function notToBeString() {
|
|
672
|
+
this._expected = true;
|
|
673
|
+
if (base.isString(this.value)) {
|
|
674
|
+
throw new TestException({
|
|
675
|
+
message: "".concat(this.value, " is string"),
|
|
676
|
+
code: 1046,
|
|
677
|
+
status: "not-is-string"
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
return this;
|
|
681
|
+
}
|
|
682
|
+
}, {
|
|
683
|
+
key: "toBeSomeString",
|
|
684
|
+
value: function toBeSomeString() {
|
|
685
|
+
this._expected = true;
|
|
686
|
+
if (!base.isSomeString(this.value)) {
|
|
687
|
+
throw new TestException({
|
|
688
|
+
message: "".concat(this.value, " is not some string"),
|
|
689
|
+
code: 1027,
|
|
690
|
+
status: "is-some-string"
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
return this;
|
|
694
|
+
}
|
|
695
|
+
}, {
|
|
696
|
+
key: "notToBeSomeString",
|
|
697
|
+
value: function notToBeSomeString() {
|
|
698
|
+
this._expected = true;
|
|
699
|
+
if (base.isSomeString(this.value)) {
|
|
700
|
+
throw new TestException({
|
|
701
|
+
message: "".concat(this.value, " is some string"),
|
|
702
|
+
code: 1047,
|
|
703
|
+
status: "not-is-some-string"
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
return this;
|
|
707
|
+
}
|
|
708
|
+
}, {
|
|
709
|
+
key: "toBeNumber",
|
|
710
|
+
value: function toBeNumber() {
|
|
711
|
+
this._expected = true;
|
|
712
|
+
if (!base.isNumber(this.value)) {
|
|
713
|
+
throw new TestException({
|
|
714
|
+
message: "".concat(this.value, " is not number"),
|
|
715
|
+
code: 1028,
|
|
716
|
+
status: "is-number"
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
return this;
|
|
720
|
+
}
|
|
721
|
+
}, {
|
|
722
|
+
key: "notToBeNumber",
|
|
723
|
+
value: function notToBeNumber() {
|
|
724
|
+
this._expected = true;
|
|
725
|
+
if (base.isNumber(this.value)) {
|
|
726
|
+
throw new TestException({
|
|
727
|
+
message: "".concat(this.value, " is number"),
|
|
728
|
+
code: 1048,
|
|
729
|
+
status: "not-is-number"
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return this;
|
|
733
|
+
}
|
|
734
|
+
}, {
|
|
735
|
+
key: "toBeDate",
|
|
736
|
+
value: function toBeDate() {
|
|
737
|
+
this._expected = true;
|
|
738
|
+
if (!base.isDate(this.value)) {
|
|
739
|
+
throw new TestException({
|
|
740
|
+
message: "".concat(this.value, " is not date"),
|
|
741
|
+
code: 1029,
|
|
742
|
+
status: "is-date"
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
return this;
|
|
746
|
+
}
|
|
747
|
+
}, {
|
|
748
|
+
key: "notToBeDate",
|
|
749
|
+
value: function notToBeDate() {
|
|
750
|
+
this._expected = true;
|
|
751
|
+
if (base.isDate(this.value)) {
|
|
752
|
+
throw new TestException({
|
|
753
|
+
message: "".concat(this.value, " is date"),
|
|
754
|
+
code: 1049,
|
|
755
|
+
status: "not-is-date"
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
return this;
|
|
759
|
+
}
|
|
760
|
+
}, {
|
|
761
|
+
key: "toBeBool",
|
|
762
|
+
value: function toBeBool() {
|
|
763
|
+
this._expected = true;
|
|
764
|
+
if (!base.isBool(this.value)) {
|
|
765
|
+
throw new TestException({
|
|
766
|
+
message: "".concat(this.value, " is not bool"),
|
|
767
|
+
code: 1030,
|
|
768
|
+
status: "is-bool"
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
return this;
|
|
772
|
+
}
|
|
773
|
+
}, {
|
|
774
|
+
key: "notToBeBool",
|
|
775
|
+
value: function notToBeBool() {
|
|
776
|
+
this._expected = true;
|
|
777
|
+
if (base.isBool(this.value)) {
|
|
778
|
+
throw new TestException({
|
|
779
|
+
message: "".concat(this.value, " is bool"),
|
|
780
|
+
code: 1050,
|
|
781
|
+
status: "not-is-bool"
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
return this;
|
|
785
|
+
}
|
|
786
|
+
}, {
|
|
787
|
+
key: "toBeBasicType",
|
|
788
|
+
value: function toBeBasicType() {
|
|
789
|
+
this._expected = true;
|
|
790
|
+
if (!base.isBasic(this.value)) {
|
|
791
|
+
throw new TestException({
|
|
792
|
+
message: "".concat(this.value, " is not basic type"),
|
|
793
|
+
code: 1031,
|
|
794
|
+
status: "is-basic-type"
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
return this;
|
|
798
|
+
}
|
|
799
|
+
}, {
|
|
800
|
+
key: "notToBeBasicType",
|
|
801
|
+
value: function notToBeBasicType() {
|
|
802
|
+
this._expected = true;
|
|
803
|
+
if (base.isBasic(this.value)) {
|
|
804
|
+
throw new TestException({
|
|
805
|
+
message: "".concat(this.value, " is basic type"),
|
|
806
|
+
code: 1051,
|
|
807
|
+
status: "not-is-basic-type"
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
return this;
|
|
811
|
+
}
|
|
812
|
+
}, {
|
|
813
|
+
key: "toBePrimitive",
|
|
814
|
+
value: function toBePrimitive() {
|
|
815
|
+
this._expected = true;
|
|
816
|
+
if (!base.isPrimitive(this.value)) {
|
|
817
|
+
throw new TestException({
|
|
818
|
+
message: "".concat(this.value, " is not primitive type"),
|
|
819
|
+
code: 1032,
|
|
820
|
+
status: "is-primitive"
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
return this;
|
|
824
|
+
}
|
|
825
|
+
}, {
|
|
826
|
+
key: "notToBePrimitive",
|
|
827
|
+
value: function notToBePrimitive() {
|
|
828
|
+
this._expected = true;
|
|
829
|
+
if (base.isPrimitive(this.value)) {
|
|
830
|
+
throw new TestException({
|
|
831
|
+
message: "".concat(this.value, " is primitive type"),
|
|
832
|
+
code: 1052,
|
|
833
|
+
status: "not-is-primitive"
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
return this;
|
|
837
|
+
}
|
|
838
|
+
}, {
|
|
839
|
+
key: "toBeEmpty",
|
|
840
|
+
value: function toBeEmpty() {
|
|
841
|
+
this._expected = true;
|
|
842
|
+
if (!base.isEmpty(this.value)) {
|
|
843
|
+
throw new TestException({
|
|
844
|
+
message: "".concat(this.value, " is not empty"),
|
|
845
|
+
code: 1033,
|
|
846
|
+
status: "is-empty"
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
return this;
|
|
850
|
+
}
|
|
851
|
+
}, {
|
|
852
|
+
key: "notToBeEmpty",
|
|
853
|
+
value: function notToBeEmpty() {
|
|
854
|
+
this._expected = true;
|
|
855
|
+
if (base.isEmpty(this.value)) {
|
|
856
|
+
throw new TestException({
|
|
857
|
+
message: "".concat(this.value, " is empty"),
|
|
858
|
+
code: 1053,
|
|
859
|
+
status: "not-is-empty"
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
return this;
|
|
863
|
+
}
|
|
864
|
+
}, {
|
|
865
|
+
key: "toBeObject",
|
|
866
|
+
value: function toBeObject() {
|
|
867
|
+
this._expected = true;
|
|
868
|
+
if (!base.isObject(this.value)) {
|
|
869
|
+
throw new TestException({
|
|
870
|
+
message: "".concat(this.value, " is not object"),
|
|
871
|
+
code: 1034,
|
|
872
|
+
status: "is-object"
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
return this;
|
|
876
|
+
}
|
|
877
|
+
}, {
|
|
878
|
+
key: "notToBeObject",
|
|
879
|
+
value: function notToBeObject() {
|
|
880
|
+
this._expected = true;
|
|
881
|
+
if (base.isObject(this.value)) {
|
|
882
|
+
throw new TestException({
|
|
883
|
+
message: "".concat(this.value, " is object"),
|
|
884
|
+
code: 1054,
|
|
885
|
+
status: "not-is-object"
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
return this;
|
|
889
|
+
}
|
|
890
|
+
}, {
|
|
891
|
+
key: "toBeSomeObject",
|
|
892
|
+
value: function toBeSomeObject() {
|
|
893
|
+
this._expected = true;
|
|
894
|
+
if (!base.isSomeObject(this.value)) {
|
|
895
|
+
throw new TestException({
|
|
896
|
+
message: "".concat(this.value, " is not some object"),
|
|
897
|
+
code: 1035,
|
|
898
|
+
status: "is-some-object"
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
return this;
|
|
902
|
+
}
|
|
903
|
+
}, {
|
|
904
|
+
key: "notToBeSomeObject",
|
|
905
|
+
value: function notToBeSomeObject() {
|
|
906
|
+
this._expected = true;
|
|
907
|
+
if (base.isSomeObject(this.value)) {
|
|
908
|
+
throw new TestException({
|
|
909
|
+
message: "".concat(this.value, " is some object"),
|
|
910
|
+
code: 1055,
|
|
911
|
+
status: "not-is-some-object"
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
return this;
|
|
915
|
+
}
|
|
916
|
+
}, {
|
|
917
|
+
key: "toBeFunction",
|
|
918
|
+
value: function toBeFunction() {
|
|
919
|
+
this._expected = true;
|
|
920
|
+
if (!base.isFunction(this.value)) {
|
|
921
|
+
throw new TestException({
|
|
922
|
+
message: "".concat(this.value, " is not function"),
|
|
923
|
+
code: 1036,
|
|
924
|
+
status: "is-function"
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
return this;
|
|
928
|
+
}
|
|
929
|
+
}, {
|
|
930
|
+
key: "notToBeFunction",
|
|
931
|
+
value: function notToBeFunction() {
|
|
932
|
+
this._expected = true;
|
|
933
|
+
if (base.isFunction(this.value)) {
|
|
934
|
+
throw new TestException({
|
|
935
|
+
message: "".concat(this.value, " is function"),
|
|
936
|
+
code: 1056,
|
|
937
|
+
status: "not-is-function"
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
return this;
|
|
941
|
+
}
|
|
942
|
+
}, {
|
|
943
|
+
key: "toBeNumeric",
|
|
944
|
+
value: function toBeNumeric() {
|
|
945
|
+
this._expected = true;
|
|
946
|
+
if (!base.isNumeric(this.value)) {
|
|
947
|
+
throw new TestException({
|
|
948
|
+
message: "".concat(this.value, " is not numeric"),
|
|
949
|
+
code: 1037,
|
|
950
|
+
status: "is-numeric"
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
return this;
|
|
954
|
+
}
|
|
955
|
+
}, {
|
|
956
|
+
key: "notToBeNumeric",
|
|
957
|
+
value: function notToBeNumeric() {
|
|
958
|
+
this._expected = true;
|
|
959
|
+
if (base.isNumeric(this.value)) {
|
|
960
|
+
throw new TestException({
|
|
961
|
+
message: "".concat(this.value, " is numeric"),
|
|
962
|
+
code: 1057,
|
|
963
|
+
status: "not-is-numeric"
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
return this;
|
|
967
|
+
}
|
|
968
|
+
}, {
|
|
969
|
+
key: "toBeArray",
|
|
970
|
+
value: function toBeArray() {
|
|
971
|
+
this._expected = true;
|
|
972
|
+
if (!base.isArray(this.value)) {
|
|
973
|
+
throw new TestException({
|
|
974
|
+
message: "".concat(this.value, " is not array"),
|
|
975
|
+
code: 1038,
|
|
976
|
+
status: "is-array"
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
return this;
|
|
980
|
+
}
|
|
981
|
+
}, {
|
|
982
|
+
key: "notToBeArray",
|
|
983
|
+
value: function notToBeArray() {
|
|
984
|
+
this._expected = true;
|
|
985
|
+
if (base.isArray(this.value)) {
|
|
986
|
+
throw new TestException({
|
|
987
|
+
message: "".concat(this.value, " is array"),
|
|
988
|
+
code: 1058,
|
|
989
|
+
status: "not-is-array"
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
return this;
|
|
993
|
+
}
|
|
994
|
+
}, {
|
|
995
|
+
key: "toBeSomeArray",
|
|
996
|
+
value: function toBeSomeArray() {
|
|
997
|
+
this._expected = true;
|
|
998
|
+
if (!base.isSomeArray(this.value)) {
|
|
999
|
+
throw new TestException({
|
|
1000
|
+
message: "".concat(this.value, " is not some array"),
|
|
1001
|
+
code: 1039,
|
|
1002
|
+
status: "is-some-array"
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
return this;
|
|
1006
|
+
}
|
|
1007
|
+
}, {
|
|
1008
|
+
key: "notToBeSomeArray",
|
|
1009
|
+
value: function notToBeSomeArray() {
|
|
1010
|
+
this._expected = true;
|
|
1011
|
+
if (!base.isArray(this.value)) {
|
|
1012
|
+
throw new TestException({
|
|
1013
|
+
message: "".concat(this.value, " is not array"),
|
|
1014
|
+
code: 1068,
|
|
1015
|
+
status: "is-not-array"
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
if (this.value.length) {
|
|
1019
|
+
throw new TestException({
|
|
1020
|
+
message: "".concat(this.value, " is array"),
|
|
1021
|
+
code: 1069,
|
|
1022
|
+
status: "is-some-array"
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
return this;
|
|
1026
|
+
}
|
|
1027
|
+
}, {
|
|
1028
|
+
key: "toBeIterable",
|
|
1029
|
+
value: function toBeIterable() {
|
|
1030
|
+
this._expected = true;
|
|
1031
|
+
if (!base.isIterable(this.value)) {
|
|
1032
|
+
throw new TestException({
|
|
1033
|
+
message: "".concat(this.value, " is not iterable"),
|
|
1034
|
+
code: 1040,
|
|
1035
|
+
status: "is-iterable"
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
return this;
|
|
1039
|
+
}
|
|
1040
|
+
}, {
|
|
1041
|
+
key: "notToBeIterable",
|
|
1042
|
+
value: function notToBeIterable() {
|
|
1043
|
+
this._expected = true;
|
|
1044
|
+
if (base.isIterable(this.value)) {
|
|
1045
|
+
throw new TestException({
|
|
1046
|
+
message: "".concat(this.value, " is iterable"),
|
|
1047
|
+
code: 1060,
|
|
1048
|
+
status: "not-iterable"
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
return this;
|
|
1052
|
+
}
|
|
1053
|
+
}, {
|
|
1054
|
+
key: "toBeSubClassOf",
|
|
1055
|
+
value: function toBeSubClassOf(type) {
|
|
1056
|
+
this._expected = true;
|
|
1057
|
+
if (!base.isSubClassOf(this.value, type)) {
|
|
1058
|
+
throw new TestException({
|
|
1059
|
+
message: "".concat(this.value, " is not subclass of ").concat(type),
|
|
1060
|
+
code: 1041,
|
|
1061
|
+
status: "is-subclass-of"
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
return this;
|
|
1065
|
+
}
|
|
1066
|
+
}, {
|
|
1067
|
+
key: "notToBeSubClassOf",
|
|
1068
|
+
value: function notToBeSubClassOf(type) {
|
|
1069
|
+
this._expected = true;
|
|
1070
|
+
if (base.isSubClassOf(this.value, type)) {
|
|
1071
|
+
throw new TestException({
|
|
1072
|
+
message: "".concat(this.value, " is subclass of ").concat(type),
|
|
1073
|
+
code: 1061,
|
|
1074
|
+
status: "not-subclassof"
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
return this;
|
|
1078
|
+
}
|
|
1079
|
+
}, {
|
|
1080
|
+
key: "toBeInstanceOf",
|
|
1081
|
+
value: function toBeInstanceOf(type) {
|
|
1082
|
+
this._expected = true;
|
|
1083
|
+
if (!(this.value instanceof type)) {
|
|
1084
|
+
throw new TestException({
|
|
1085
|
+
message: "".concat(this.value, " is not instance of ").concat(type),
|
|
1086
|
+
code: 1042,
|
|
1087
|
+
status: "instanceof"
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
return this;
|
|
1091
|
+
}
|
|
1092
|
+
}, {
|
|
1093
|
+
key: "notToBeInstanceOf",
|
|
1094
|
+
value: function notToBeInstanceOf(type) {
|
|
1095
|
+
this._expected = true;
|
|
1096
|
+
if (this.value instanceof type) {
|
|
1097
|
+
throw new TestException({
|
|
1098
|
+
message: "".concat(this.value, " is instance of ").concat(type),
|
|
1099
|
+
code: 1062,
|
|
1100
|
+
status: "not-instanceof"
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
return this;
|
|
1104
|
+
}
|
|
1105
|
+
}, {
|
|
1106
|
+
key: "toMatch",
|
|
1107
|
+
value: function toMatch(pattern, flags) {
|
|
1108
|
+
this._expected = true;
|
|
1109
|
+
var r = new RegExp(pattern, flags);
|
|
1110
|
+
if (!r.test(this.value)) {
|
|
1111
|
+
throw new TestException({
|
|
1112
|
+
message: "".concat(this.value, " does not match ").concat(pattern),
|
|
1113
|
+
code: 1043,
|
|
1114
|
+
status: "match"
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
return this;
|
|
1118
|
+
}
|
|
1119
|
+
}, {
|
|
1120
|
+
key: "notToMatch",
|
|
1121
|
+
value: function notToMatch(pattern, flags) {
|
|
1122
|
+
this._expected = true;
|
|
1123
|
+
var r = new RegExp(pattern, flags);
|
|
1124
|
+
if (r.test(this.value)) {
|
|
1125
|
+
throw new TestException({
|
|
1126
|
+
message: "".concat(this.value, " matches ").concat(pattern),
|
|
1127
|
+
code: 1070,
|
|
1128
|
+
status: "match"
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
return this;
|
|
1132
|
+
}
|
|
1133
|
+
}, {
|
|
1134
|
+
key: "doesNotMatch",
|
|
1135
|
+
value: function doesNotMatch(pattern, flags) {
|
|
1136
|
+
this._expected = true;
|
|
1137
|
+
var r = new RegExp(pattern, flags);
|
|
1138
|
+
if (r.test(this.value)) {
|
|
1139
|
+
throw new TestException({
|
|
1140
|
+
message: "".concat(this.value, " matches ").concat(pattern),
|
|
1141
|
+
code: 1063,
|
|
1142
|
+
status: "not-match"
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
return this;
|
|
1146
|
+
}
|
|
1147
|
+
}, {
|
|
1148
|
+
key: "toBeDefined",
|
|
1149
|
+
value: function toBeDefined() {
|
|
1150
|
+
this._expected = true;
|
|
1151
|
+
if (this.value === undefined) {
|
|
1152
|
+
throw new TestException({
|
|
1153
|
+
message: "value is undefined",
|
|
1154
|
+
code: 1006,
|
|
1155
|
+
status: "undefined"
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
return this;
|
|
1159
|
+
}
|
|
1160
|
+
}, {
|
|
1161
|
+
key: "notToBeDefined",
|
|
1162
|
+
value: function notToBeDefined() {
|
|
1163
|
+
this._expected = true;
|
|
1164
|
+
if (this.value !== undefined) {
|
|
1165
|
+
throw new TestException({
|
|
1166
|
+
message: "value is defined",
|
|
1167
|
+
code: 1071,
|
|
1168
|
+
status: "defined"
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
return this;
|
|
1172
|
+
}
|
|
1173
|
+
}, {
|
|
1174
|
+
key: "toBeUndefined",
|
|
1175
|
+
value: function toBeUndefined() {
|
|
1176
|
+
this._expected = true;
|
|
1177
|
+
if (this.value !== undefined) {
|
|
1178
|
+
throw new TestException({
|
|
1179
|
+
message: "value is defined",
|
|
1180
|
+
code: 1007,
|
|
1181
|
+
status: "defined"
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
return this;
|
|
1185
|
+
}
|
|
1186
|
+
}, {
|
|
1187
|
+
key: "notToBeUndefined",
|
|
1188
|
+
value: function notToBeUndefined() {
|
|
1189
|
+
this._expected = true;
|
|
1190
|
+
if (this.value === undefined) {
|
|
1191
|
+
throw new TestException({
|
|
1192
|
+
message: "value is undefined",
|
|
1193
|
+
code: 1072,
|
|
1194
|
+
status: "undefined"
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
return this;
|
|
1198
|
+
}
|
|
1199
|
+
}, {
|
|
1200
|
+
key: "toBeNull",
|
|
1201
|
+
value: function toBeNull() {
|
|
1202
|
+
this._expected = true;
|
|
1203
|
+
if (this.value !== null) {
|
|
1204
|
+
throw new TestException({
|
|
1205
|
+
message: "value is not null",
|
|
1206
|
+
code: 1008,
|
|
1207
|
+
status: "not-null"
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
return this;
|
|
1211
|
+
}
|
|
1212
|
+
}, {
|
|
1213
|
+
key: "notToBeNull",
|
|
1214
|
+
value: function notToBeNull() {
|
|
1215
|
+
this._expected = true;
|
|
1216
|
+
if (this.value === null) {
|
|
1217
|
+
throw new TestException({
|
|
1218
|
+
message: "value is null",
|
|
1219
|
+
code: 1009,
|
|
1220
|
+
status: "null"
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
return this;
|
|
1224
|
+
}
|
|
1225
|
+
}, {
|
|
1226
|
+
key: "toBeNullOrUndefined",
|
|
1227
|
+
value: function toBeNullOrUndefined() {
|
|
1228
|
+
this._expected = true;
|
|
1229
|
+
if (this.value == null) ; else {
|
|
1230
|
+
throw new TestException({
|
|
1231
|
+
message: "value is not null/undefined",
|
|
1232
|
+
code: 1010,
|
|
1233
|
+
status: "not-null-or-undefined"
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
return this;
|
|
1237
|
+
}
|
|
1238
|
+
}, {
|
|
1239
|
+
key: "notToBeNullOrUndefined",
|
|
1240
|
+
value: function notToBeNullOrUndefined() {
|
|
1241
|
+
this._expected = true;
|
|
1242
|
+
if (this.value == null) {
|
|
1243
|
+
throw new TestException({
|
|
1244
|
+
message: "value is null/undefined",
|
|
1245
|
+
code: 1011,
|
|
1246
|
+
status: "null-or-undefined"
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
return this;
|
|
1250
|
+
}
|
|
1251
|
+
}, {
|
|
1252
|
+
key: "toBeEmptyArray",
|
|
1253
|
+
value: function toBeEmptyArray() {
|
|
1254
|
+
this._expected = true;
|
|
1255
|
+
if (base.isSomeArray(this.value)) {
|
|
1256
|
+
throw new TestException({
|
|
1257
|
+
message: "".concat(this.value, " is some array"),
|
|
1258
|
+
code: 1059,
|
|
1259
|
+
status: "to-be-empty-array"
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
return this;
|
|
1263
|
+
}
|
|
1264
|
+
}, {
|
|
1265
|
+
key: "toBeValid",
|
|
1266
|
+
value: function toBeValid(fnValidation) {
|
|
1267
|
+
this._expected = true;
|
|
1268
|
+
if (!base.isFunction(fnValidation)) {
|
|
1269
|
+
throw new TestException({
|
|
1270
|
+
message: "fnValidation is not function",
|
|
1271
|
+
code: 1064,
|
|
1272
|
+
status: "to-be-valid"
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
if (!fnValidation(this.value)) {
|
|
1276
|
+
throw new TestException({
|
|
1277
|
+
message: "".concat(this.value, " is not valid"),
|
|
1278
|
+
code: 1065,
|
|
1279
|
+
status: "to-be-valid"
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
return this;
|
|
1283
|
+
}
|
|
1284
|
+
}, {
|
|
1285
|
+
key: "notToBeValid",
|
|
1286
|
+
value: function notToBeValid(fnValidation) {
|
|
1287
|
+
this._expected = true;
|
|
1288
|
+
if (!base.isFunction(fnValidation)) {
|
|
1289
|
+
throw new TestException({
|
|
1290
|
+
message: "fnValidation is not function",
|
|
1291
|
+
code: 1066,
|
|
1292
|
+
status: "not-to-be-valid"
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
if (fnValidation(this.value)) {
|
|
1296
|
+
throw new TestException({
|
|
1297
|
+
message: "".concat(this.value, " is valid"),
|
|
1298
|
+
code: 1067,
|
|
1299
|
+
status: "not-to-be-valid"
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
return this;
|
|
1303
|
+
}
|
|
1304
|
+
}, {
|
|
1305
|
+
key: "toThrow",
|
|
1306
|
+
value: function toThrow(ex) {
|
|
1307
|
+
var shape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1308
|
+
var strict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1309
|
+
this._expected = true;
|
|
1310
|
+
if (!base.isFunction(this.value)) {
|
|
1311
|
+
throw new TestException({
|
|
1312
|
+
message: "given argument is not a function.",
|
|
1313
|
+
code: 1012,
|
|
1314
|
+
status: "not-func"
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
var ok = false;
|
|
1318
|
+
try {
|
|
1319
|
+
this.value();
|
|
1320
|
+
ok = true;
|
|
1321
|
+
} catch (e) {
|
|
1322
|
+
if (ex !== undefined) {
|
|
1323
|
+
if (base.isPrimitive(ex)) {
|
|
1324
|
+
if (e !== ex) {
|
|
1325
|
+
throw new TestException({
|
|
1326
|
+
message: "given function threw incorrect error.",
|
|
1327
|
+
code: 1018,
|
|
1328
|
+
status: "incorrect-throw-error"
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
} else if (base.isFunction(ex)) {
|
|
1332
|
+
if (!(e instanceof ex)) {
|
|
1333
|
+
throw new TestException({
|
|
1334
|
+
message: "given function threw incorrect instance.",
|
|
1335
|
+
code: 1019,
|
|
1336
|
+
status: "incorrect-throw-instance"
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
} else if (base.isObject(ex)) {
|
|
1340
|
+
if (shape) {
|
|
1341
|
+
if (!base.equals(e, ex, strict)) {
|
|
1342
|
+
throw new TestException({
|
|
1343
|
+
message: "given function threw incorrect object shape.",
|
|
1344
|
+
code: 1020,
|
|
1345
|
+
status: "incorrect-throw-shape"
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
} else {
|
|
1349
|
+
if (e !== ex) {
|
|
1350
|
+
throw new TestException({
|
|
1351
|
+
message: "given function threw incorrect object.",
|
|
1352
|
+
code: 1021,
|
|
1353
|
+
status: "incorrect-throw-object"
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
} else {
|
|
1358
|
+
if (e !== ex) {
|
|
1359
|
+
throw new TestException({
|
|
1360
|
+
message: "given function threw incorrect value.",
|
|
1361
|
+
code: 1022,
|
|
1362
|
+
status: "incorrect-throw-value"
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
} else {
|
|
1367
|
+
ok = false;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
if (ok) {
|
|
1371
|
+
throw new TestException({
|
|
1372
|
+
message: "given function ran without throwing any errors.",
|
|
1373
|
+
code: 1013,
|
|
1374
|
+
status: "ran-to-completion"
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
return this;
|
|
1378
|
+
}
|
|
1379
|
+
}, {
|
|
1380
|
+
key: "notToThrow",
|
|
1381
|
+
value: function notToThrow(ex) {
|
|
1382
|
+
var shape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1383
|
+
var strict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1384
|
+
this._expected = true;
|
|
1385
|
+
if (!base.isFunction(this.value)) {
|
|
1386
|
+
throw new TestException({
|
|
1387
|
+
message: "given argument is not a function.",
|
|
1388
|
+
code: 1012,
|
|
1389
|
+
status: "not-func"
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
var ok = true;
|
|
1393
|
+
var error;
|
|
1394
|
+
try {
|
|
1395
|
+
this.value();
|
|
1396
|
+
ok = false;
|
|
1397
|
+
} catch (e) {
|
|
1398
|
+
error = e;
|
|
1399
|
+
if (ex !== undefined) {
|
|
1400
|
+
if (base.isPrimitive(ex)) {
|
|
1401
|
+
if (e === ex) {
|
|
1402
|
+
throw new TestException({
|
|
1403
|
+
message: "given function threw incorrect error.",
|
|
1404
|
+
code: 1018,
|
|
1405
|
+
status: "incorrect-throw-error"
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
} else if (base.isFunction(ex)) {
|
|
1409
|
+
if (e instanceof ex) {
|
|
1410
|
+
throw new TestException({
|
|
1411
|
+
message: "given function threw incorrect instance.",
|
|
1412
|
+
code: 1019,
|
|
1413
|
+
status: "incorrect-throw-instance"
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
} else if (base.isObject(ex)) {
|
|
1417
|
+
if (shape) {
|
|
1418
|
+
if (base.equals(e, ex, strict)) {
|
|
1419
|
+
throw new TestException({
|
|
1420
|
+
message: "given function threw incorrect object shape.",
|
|
1421
|
+
code: 1020,
|
|
1422
|
+
status: "incorrect-throw-shape"
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
} else {
|
|
1426
|
+
if (e === ex) {
|
|
1427
|
+
throw new TestException({
|
|
1428
|
+
message: "given function threw incorrect object.",
|
|
1429
|
+
code: 1021,
|
|
1430
|
+
status: "incorrect-throw-object"
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
} else {
|
|
1435
|
+
if (e === ex) {
|
|
1436
|
+
throw new TestException({
|
|
1437
|
+
message: "given function threw incorrect value.",
|
|
1438
|
+
code: 1022,
|
|
1439
|
+
status: "incorrect-throw-value"
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
} else {
|
|
1444
|
+
ok = true;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
if (ok) {
|
|
1448
|
+
throw new TestException({
|
|
1449
|
+
message: "given function threw an error.",
|
|
1450
|
+
code: 1014,
|
|
1451
|
+
status: "ran-to-error",
|
|
1452
|
+
innerException: error
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
return this;
|
|
1456
|
+
}
|
|
1457
|
+
}, {
|
|
1458
|
+
key: "toThrowAsync",
|
|
1459
|
+
value: function () {
|
|
1460
|
+
var _toThrowAsync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(ex) {
|
|
1461
|
+
var shape,
|
|
1462
|
+
strict,
|
|
1463
|
+
ok,
|
|
1464
|
+
_args = arguments;
|
|
1465
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1466
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1467
|
+
case 0:
|
|
1468
|
+
shape = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
1469
|
+
strict = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
|
1470
|
+
this._expected = true;
|
|
1471
|
+
if (base.isFunction(this.value)) {
|
|
1472
|
+
_context.next = 5;
|
|
1473
|
+
break;
|
|
1474
|
+
}
|
|
1475
|
+
throw new TestException({
|
|
1476
|
+
message: "given argument is not a function.",
|
|
1477
|
+
code: 1012,
|
|
1478
|
+
status: "not-func"
|
|
1479
|
+
});
|
|
1480
|
+
case 5:
|
|
1481
|
+
ok = false;
|
|
1482
|
+
_context.prev = 6;
|
|
1483
|
+
_context.next = 9;
|
|
1484
|
+
return this.value();
|
|
1485
|
+
case 9:
|
|
1486
|
+
ok = true;
|
|
1487
|
+
_context.next = 40;
|
|
1488
|
+
break;
|
|
1489
|
+
case 12:
|
|
1490
|
+
_context.prev = 12;
|
|
1491
|
+
_context.t0 = _context["catch"](6);
|
|
1492
|
+
if (!(ex !== undefined)) {
|
|
1493
|
+
_context.next = 39;
|
|
1494
|
+
break;
|
|
1495
|
+
}
|
|
1496
|
+
if (!base.isPrimitive(ex)) {
|
|
1497
|
+
_context.next = 20;
|
|
1498
|
+
break;
|
|
1499
|
+
}
|
|
1500
|
+
if (!(_context.t0 !== ex)) {
|
|
1501
|
+
_context.next = 18;
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
throw new TestException({
|
|
1505
|
+
message: "given function threw incorrect error.",
|
|
1506
|
+
code: 1018,
|
|
1507
|
+
status: "incorrect-throw-error"
|
|
1508
|
+
});
|
|
1509
|
+
case 18:
|
|
1510
|
+
_context.next = 37;
|
|
1511
|
+
break;
|
|
1512
|
+
case 20:
|
|
1513
|
+
if (!base.isFunction(ex)) {
|
|
1514
|
+
_context.next = 25;
|
|
1515
|
+
break;
|
|
1516
|
+
}
|
|
1517
|
+
if (_context.t0 instanceof ex) {
|
|
1518
|
+
_context.next = 23;
|
|
1519
|
+
break;
|
|
1520
|
+
}
|
|
1521
|
+
throw new TestException({
|
|
1522
|
+
message: "given function threw incorrect instance.",
|
|
1523
|
+
code: 1019,
|
|
1524
|
+
status: "incorrect-throw-instance"
|
|
1525
|
+
});
|
|
1526
|
+
case 23:
|
|
1527
|
+
_context.next = 37;
|
|
1528
|
+
break;
|
|
1529
|
+
case 25:
|
|
1530
|
+
if (!base.isObject(ex)) {
|
|
1531
|
+
_context.next = 35;
|
|
1532
|
+
break;
|
|
1533
|
+
}
|
|
1534
|
+
if (!shape) {
|
|
1535
|
+
_context.next = 31;
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
if (base.equals(_context.t0, ex, strict)) {
|
|
1539
|
+
_context.next = 29;
|
|
1540
|
+
break;
|
|
1541
|
+
}
|
|
1542
|
+
throw new TestException({
|
|
1543
|
+
message: "given function threw incorrect object shape.",
|
|
1544
|
+
code: 1020,
|
|
1545
|
+
status: "incorrect-throw-shape"
|
|
1546
|
+
});
|
|
1547
|
+
case 29:
|
|
1548
|
+
_context.next = 33;
|
|
1549
|
+
break;
|
|
1550
|
+
case 31:
|
|
1551
|
+
if (!(_context.t0 !== ex)) {
|
|
1552
|
+
_context.next = 33;
|
|
1553
|
+
break;
|
|
1554
|
+
}
|
|
1555
|
+
throw new TestException({
|
|
1556
|
+
message: "given function threw incorrect object.",
|
|
1557
|
+
code: 1021,
|
|
1558
|
+
status: "incorrect-throw-object"
|
|
1559
|
+
});
|
|
1560
|
+
case 33:
|
|
1561
|
+
_context.next = 37;
|
|
1562
|
+
break;
|
|
1563
|
+
case 35:
|
|
1564
|
+
if (!(_context.t0 !== ex)) {
|
|
1565
|
+
_context.next = 37;
|
|
1566
|
+
break;
|
|
1567
|
+
}
|
|
1568
|
+
throw new TestException({
|
|
1569
|
+
message: "given function threw incorrect value.",
|
|
1570
|
+
code: 1022,
|
|
1571
|
+
status: "incorrect-throw-value"
|
|
1572
|
+
});
|
|
1573
|
+
case 37:
|
|
1574
|
+
_context.next = 40;
|
|
1575
|
+
break;
|
|
1576
|
+
case 39:
|
|
1577
|
+
ok = false;
|
|
1578
|
+
case 40:
|
|
1579
|
+
if (!ok) {
|
|
1580
|
+
_context.next = 42;
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
throw new TestException({
|
|
1584
|
+
message: "given function ran without throwing any errors.",
|
|
1585
|
+
code: 1013,
|
|
1586
|
+
status: "ran-to-completion"
|
|
1587
|
+
});
|
|
1588
|
+
case 42:
|
|
1589
|
+
return _context.abrupt("return", this);
|
|
1590
|
+
case 43:
|
|
1591
|
+
case "end":
|
|
1592
|
+
return _context.stop();
|
|
1593
|
+
}
|
|
1594
|
+
}, _callee, this, [[6, 12]]);
|
|
1595
|
+
}));
|
|
1596
|
+
function toThrowAsync(_x) {
|
|
1597
|
+
return _toThrowAsync.apply(this, arguments);
|
|
1598
|
+
}
|
|
1599
|
+
return toThrowAsync;
|
|
1600
|
+
}()
|
|
1601
|
+
}, {
|
|
1602
|
+
key: "notToThrowAsync",
|
|
1603
|
+
value: function () {
|
|
1604
|
+
var _notToThrowAsync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ex) {
|
|
1605
|
+
var shape,
|
|
1606
|
+
strict,
|
|
1607
|
+
ok,
|
|
1608
|
+
error,
|
|
1609
|
+
_args2 = arguments;
|
|
1610
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1611
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1612
|
+
case 0:
|
|
1613
|
+
shape = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : false;
|
|
1614
|
+
strict = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
|
|
1615
|
+
this._expected = true;
|
|
1616
|
+
if (base.isFunction(this.value)) {
|
|
1617
|
+
_context2.next = 5;
|
|
1618
|
+
break;
|
|
1619
|
+
}
|
|
1620
|
+
throw new TestException({
|
|
1621
|
+
message: "given argument is not a function.",
|
|
1622
|
+
code: 1012,
|
|
1623
|
+
status: "not-func"
|
|
1624
|
+
});
|
|
1625
|
+
case 5:
|
|
1626
|
+
ok = true;
|
|
1627
|
+
_context2.prev = 6;
|
|
1628
|
+
_context2.next = 9;
|
|
1629
|
+
return this.value();
|
|
1630
|
+
case 9:
|
|
1631
|
+
ok = false;
|
|
1632
|
+
_context2.next = 41;
|
|
1633
|
+
break;
|
|
1634
|
+
case 12:
|
|
1635
|
+
_context2.prev = 12;
|
|
1636
|
+
_context2.t0 = _context2["catch"](6);
|
|
1637
|
+
error = _context2.t0;
|
|
1638
|
+
if (!(ex !== undefined)) {
|
|
1639
|
+
_context2.next = 40;
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
if (!base.isPrimitive(ex)) {
|
|
1643
|
+
_context2.next = 21;
|
|
1644
|
+
break;
|
|
1645
|
+
}
|
|
1646
|
+
if (!(_context2.t0 === ex)) {
|
|
1647
|
+
_context2.next = 19;
|
|
1648
|
+
break;
|
|
1649
|
+
}
|
|
1650
|
+
throw new TestException({
|
|
1651
|
+
message: "given function threw incorrect error.",
|
|
1652
|
+
code: 1018,
|
|
1653
|
+
status: "incorrect-throw-error"
|
|
1654
|
+
});
|
|
1655
|
+
case 19:
|
|
1656
|
+
_context2.next = 38;
|
|
1657
|
+
break;
|
|
1658
|
+
case 21:
|
|
1659
|
+
if (!base.isFunction(ex)) {
|
|
1660
|
+
_context2.next = 26;
|
|
1661
|
+
break;
|
|
1662
|
+
}
|
|
1663
|
+
if (!(_context2.t0 instanceof ex)) {
|
|
1664
|
+
_context2.next = 24;
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1667
|
+
throw new TestException({
|
|
1668
|
+
message: "given function threw incorrect instance.",
|
|
1669
|
+
code: 1019,
|
|
1670
|
+
status: "incorrect-throw-instance"
|
|
1671
|
+
});
|
|
1672
|
+
case 24:
|
|
1673
|
+
_context2.next = 38;
|
|
1674
|
+
break;
|
|
1675
|
+
case 26:
|
|
1676
|
+
if (!base.isObject(ex)) {
|
|
1677
|
+
_context2.next = 36;
|
|
1678
|
+
break;
|
|
1679
|
+
}
|
|
1680
|
+
if (!shape) {
|
|
1681
|
+
_context2.next = 32;
|
|
1682
|
+
break;
|
|
1683
|
+
}
|
|
1684
|
+
if (!base.equals(_context2.t0, ex, strict)) {
|
|
1685
|
+
_context2.next = 30;
|
|
1686
|
+
break;
|
|
1687
|
+
}
|
|
1688
|
+
throw new TestException({
|
|
1689
|
+
message: "given function threw incorrect object shape.",
|
|
1690
|
+
code: 1020,
|
|
1691
|
+
status: "incorrect-throw-shape"
|
|
1692
|
+
});
|
|
1693
|
+
case 30:
|
|
1694
|
+
_context2.next = 34;
|
|
1695
|
+
break;
|
|
1696
|
+
case 32:
|
|
1697
|
+
if (!(_context2.t0 === ex)) {
|
|
1698
|
+
_context2.next = 34;
|
|
1699
|
+
break;
|
|
1700
|
+
}
|
|
1701
|
+
throw new TestException({
|
|
1702
|
+
message: "given function threw incorrect object.",
|
|
1703
|
+
code: 1021,
|
|
1704
|
+
status: "incorrect-throw-object"
|
|
1705
|
+
});
|
|
1706
|
+
case 34:
|
|
1707
|
+
_context2.next = 38;
|
|
1708
|
+
break;
|
|
1709
|
+
case 36:
|
|
1710
|
+
if (!(_context2.t0 === ex)) {
|
|
1711
|
+
_context2.next = 38;
|
|
1712
|
+
break;
|
|
1713
|
+
}
|
|
1714
|
+
throw new TestException({
|
|
1715
|
+
message: "given function threw incorrect value.",
|
|
1716
|
+
code: 1022,
|
|
1717
|
+
status: "incorrect-throw-value"
|
|
1718
|
+
});
|
|
1719
|
+
case 38:
|
|
1720
|
+
_context2.next = 41;
|
|
1721
|
+
break;
|
|
1722
|
+
case 40:
|
|
1723
|
+
ok = true;
|
|
1724
|
+
case 41:
|
|
1725
|
+
if (!ok) {
|
|
1726
|
+
_context2.next = 43;
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1729
|
+
throw new TestException({
|
|
1730
|
+
message: "given function threw an error.",
|
|
1731
|
+
code: 1014,
|
|
1732
|
+
status: "ran-to-error",
|
|
1733
|
+
innerException: error
|
|
1734
|
+
});
|
|
1735
|
+
case 43:
|
|
1736
|
+
return _context2.abrupt("return", this);
|
|
1737
|
+
case 44:
|
|
1738
|
+
case "end":
|
|
1739
|
+
return _context2.stop();
|
|
1740
|
+
}
|
|
1741
|
+
}, _callee2, this, [[6, 12]]);
|
|
1742
|
+
}));
|
|
1743
|
+
function notToThrowAsync(_x2) {
|
|
1744
|
+
return _notToThrowAsync.apply(this, arguments);
|
|
1745
|
+
}
|
|
1746
|
+
return notToThrowAsync;
|
|
1747
|
+
}()
|
|
1748
|
+
}, {
|
|
1749
|
+
key: "toBeTruthy",
|
|
1750
|
+
value: function toBeTruthy() {
|
|
1751
|
+
this._expected = true;
|
|
1752
|
+
if (this.value) ; else {
|
|
1753
|
+
throw new TestException({
|
|
1754
|
+
message: "".concat(this.value, " is not truthy"),
|
|
1755
|
+
code: 1015,
|
|
1756
|
+
status: "not-truthy"
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
return this;
|
|
1760
|
+
}
|
|
1761
|
+
}, {
|
|
1762
|
+
key: "toBeTrue",
|
|
1763
|
+
value: function toBeTrue() {
|
|
1764
|
+
return this.toBeTruthy();
|
|
1765
|
+
}
|
|
1766
|
+
}, {
|
|
1767
|
+
key: "toBeFalsy",
|
|
1768
|
+
value: function toBeFalsy() {
|
|
1769
|
+
this._expected = true;
|
|
1770
|
+
if (!this.value) ; else {
|
|
1771
|
+
throw new TestException({
|
|
1772
|
+
message: "".concat(this.value, " is not falsy"),
|
|
1773
|
+
code: 1016,
|
|
1774
|
+
status: "not-falsy"
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
return this;
|
|
1778
|
+
}
|
|
1779
|
+
}, {
|
|
1780
|
+
key: "toBeFalse",
|
|
1781
|
+
value: function toBeFalse() {
|
|
1782
|
+
return this.toBeFalsy();
|
|
1783
|
+
}
|
|
1784
|
+
}, {
|
|
1785
|
+
key: "toBeNaN",
|
|
1786
|
+
value: function toBeNaN() {
|
|
1787
|
+
this._expected = true;
|
|
1788
|
+
if (isNaN(this.value)) ; else {
|
|
1789
|
+
throw new TestException({
|
|
1790
|
+
message: "".concat(this.value, " is not NaN"),
|
|
1791
|
+
code: 1017,
|
|
1792
|
+
status: "not-nan"
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
return this;
|
|
1796
|
+
}
|
|
1797
|
+
}, {
|
|
1798
|
+
key: "notToBeNaN",
|
|
1799
|
+
value: function notToBeNaN() {
|
|
1800
|
+
this._expected = true;
|
|
1801
|
+
if (!isNaN(this.value)) ; else {
|
|
1802
|
+
throw new TestException({
|
|
1803
|
+
message: "".concat(this.value, " is NaN"),
|
|
1804
|
+
code: 1023,
|
|
1805
|
+
status: "is-nan"
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
return this;
|
|
1809
|
+
}
|
|
1810
|
+
}]);
|
|
1811
|
+
}();
|
|
1812
|
+
|
|
1813
|
+
var Test = /*#__PURE__*/function () {
|
|
1814
|
+
function Test(name, fn) {
|
|
1815
|
+
_classCallCheck(this, Test);
|
|
1816
|
+
this.name = name;
|
|
1817
|
+
this.fn = fn;
|
|
1818
|
+
}
|
|
1819
|
+
return _createClass(Test, [{
|
|
1820
|
+
key: "run",
|
|
1821
|
+
value: function run() {
|
|
1822
|
+
var _this = this;
|
|
1823
|
+
return new Promise(function (res) {
|
|
1824
|
+
var start = new Date();
|
|
1825
|
+
if (base.isFunction(_this.fn)) {
|
|
1826
|
+
var _expect = new Expect();
|
|
1827
|
+
try {
|
|
1828
|
+
var _result = _this.fn(function (x) {
|
|
1829
|
+
_expect.value = x;
|
|
1830
|
+
return _expect;
|
|
1831
|
+
});
|
|
1832
|
+
if (_result && base.isFunction(_result.then)) {
|
|
1833
|
+
_result.then(function (result) {
|
|
1834
|
+
res({
|
|
1835
|
+
success: true,
|
|
1836
|
+
test: _this.name,
|
|
1837
|
+
result: result,
|
|
1838
|
+
time: new Date() - start,
|
|
1839
|
+
expected: _expect.expected
|
|
1840
|
+
});
|
|
1841
|
+
})["catch"](function (ex) {
|
|
1842
|
+
res({
|
|
1843
|
+
success: false,
|
|
1844
|
+
test: _this.name,
|
|
1845
|
+
time: new Date() - start,
|
|
1846
|
+
expected: _expect.expected,
|
|
1847
|
+
err: new TestException({
|
|
1848
|
+
message: "test '".concat(_this.name, "' failed."),
|
|
1849
|
+
code: 501,
|
|
1850
|
+
status: "failed",
|
|
1851
|
+
innerException: ex
|
|
1852
|
+
})
|
|
1853
|
+
});
|
|
1854
|
+
});
|
|
1855
|
+
} else {
|
|
1856
|
+
res({
|
|
1857
|
+
success: true,
|
|
1858
|
+
test: _this.name,
|
|
1859
|
+
time: new Date() - start,
|
|
1860
|
+
result: _result,
|
|
1861
|
+
expected: _expect.expected
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
} catch (ex) {
|
|
1865
|
+
res({
|
|
1866
|
+
success: false,
|
|
1867
|
+
test: _this.name,
|
|
1868
|
+
time: new Date() - start,
|
|
1869
|
+
expected: _expect.expected,
|
|
1870
|
+
err: new TestException({
|
|
1871
|
+
message: "test '".concat(_this.name, "' failed."),
|
|
1872
|
+
code: 501,
|
|
1873
|
+
status: "failed",
|
|
1874
|
+
innerException: ex
|
|
1875
|
+
})
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
} else {
|
|
1879
|
+
res({
|
|
1880
|
+
success: false,
|
|
1881
|
+
test: _this.name,
|
|
1882
|
+
time: new Date() - start,
|
|
1883
|
+
err: new TestException({
|
|
1884
|
+
message: "test '".concat(_this.name, "' does not have a function to be called."),
|
|
1885
|
+
code: 500,
|
|
1886
|
+
status: "no-func"
|
|
1887
|
+
})
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
}]);
|
|
1893
|
+
}();
|
|
1894
|
+
|
|
1895
|
+
var reset = "\x1b[0m";
|
|
1896
|
+
var bright = "\x1b[1m";
|
|
1897
|
+
var fgRed = "\x1b[31m";
|
|
1898
|
+
var fgGreen = "\x1b[32m";
|
|
1899
|
+
var fgYellow = "\x1b[33m";
|
|
1900
|
+
var fgMagenta = "\x1b[35m";
|
|
1901
|
+
var fgWhite = "\x1b[37m";
|
|
1902
|
+
var fgGray = "\x1b[90m";
|
|
1903
|
+
var TestRunner = /*#__PURE__*/function () {
|
|
1904
|
+
function TestRunner() {
|
|
1905
|
+
_classCallCheck(this, TestRunner);
|
|
1906
|
+
this._init();
|
|
1907
|
+
}
|
|
1908
|
+
return _createClass(TestRunner, [{
|
|
1909
|
+
key: "_init",
|
|
1910
|
+
value: function _init() {
|
|
1911
|
+
this._passed = 0;
|
|
1912
|
+
this._failed = 0;
|
|
1913
|
+
this._faulted = 0;
|
|
1914
|
+
this._unknown = 0;
|
|
1915
|
+
this._results = [];
|
|
1916
|
+
this._errors = [];
|
|
1917
|
+
}
|
|
1918
|
+
}, {
|
|
1919
|
+
key: "_runSingle",
|
|
1920
|
+
value: function () {
|
|
1921
|
+
var _runSingle2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(test, onProgress, i) {
|
|
1922
|
+
var tr;
|
|
1923
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1924
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1925
|
+
case 0:
|
|
1926
|
+
if (base.isFunction(onProgress)) {
|
|
1927
|
+
try {
|
|
1928
|
+
onProgress({
|
|
1929
|
+
source: this,
|
|
1930
|
+
test: test,
|
|
1931
|
+
index: i
|
|
1932
|
+
});
|
|
1933
|
+
} catch (ex) {
|
|
1934
|
+
this._errors.push({
|
|
1935
|
+
index: i,
|
|
1936
|
+
test: test.name,
|
|
1937
|
+
err: new TestException({
|
|
1938
|
+
message: "onProgress failed for test '".concat(test.name, " at index ").concat(i, "'."),
|
|
1939
|
+
code: 1500,
|
|
1940
|
+
status: "progress-failed",
|
|
1941
|
+
innerException: ex
|
|
1942
|
+
})
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (test instanceof Test) {
|
|
1947
|
+
_context.next = 6;
|
|
1948
|
+
break;
|
|
1949
|
+
}
|
|
1950
|
+
this._unknown++;
|
|
1951
|
+
this._errors.push({
|
|
1952
|
+
index: i,
|
|
1953
|
+
err: new TestException({
|
|
1954
|
+
message: "Given test is not an instance of '@locustjs/test:Test' class.",
|
|
1955
|
+
code: 1504,
|
|
1956
|
+
status: "invalid-test"
|
|
1957
|
+
})
|
|
1958
|
+
});
|
|
1959
|
+
_context.next = 11;
|
|
1960
|
+
break;
|
|
1961
|
+
case 6:
|
|
1962
|
+
_context.next = 8;
|
|
1963
|
+
return test.run();
|
|
1964
|
+
case 8:
|
|
1965
|
+
tr = _context.sent;
|
|
1966
|
+
this._results.push(tr);
|
|
1967
|
+
if (base.isObject(tr.err)) {
|
|
1968
|
+
if (!tr.expected) {
|
|
1969
|
+
this._faulted++;
|
|
1970
|
+
} else {
|
|
1971
|
+
this._failed++;
|
|
1972
|
+
}
|
|
1973
|
+
} else if (!tr.expected) {
|
|
1974
|
+
this._unknown++;
|
|
1975
|
+
} else if (tr.success) {
|
|
1976
|
+
this._passed++;
|
|
1977
|
+
} else {
|
|
1978
|
+
this._failed++;
|
|
1979
|
+
}
|
|
1980
|
+
case 11:
|
|
1981
|
+
case "end":
|
|
1982
|
+
return _context.stop();
|
|
1983
|
+
}
|
|
1984
|
+
}, _callee, this);
|
|
1985
|
+
}));
|
|
1986
|
+
function _runSingle(_x, _x2, _x3) {
|
|
1987
|
+
return _runSingle2.apply(this, arguments);
|
|
1988
|
+
}
|
|
1989
|
+
return _runSingle;
|
|
1990
|
+
}()
|
|
1991
|
+
}, {
|
|
1992
|
+
key: "result",
|
|
1993
|
+
get: function get() {
|
|
1994
|
+
return {
|
|
1995
|
+
passed: this._passed,
|
|
1996
|
+
failed: this._failed,
|
|
1997
|
+
faulted: this._faulted,
|
|
1998
|
+
results: this._results,
|
|
1999
|
+
errors: this._errors
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
}, {
|
|
2003
|
+
key: "run",
|
|
2004
|
+
value: function run(tests, onProgress) {
|
|
2005
|
+
var _this = this;
|
|
2006
|
+
this._init();
|
|
2007
|
+
return new Promise(function (res) {
|
|
2008
|
+
if (tests) {
|
|
2009
|
+
if (tests instanceof Test) {
|
|
2010
|
+
tests = [tests];
|
|
2011
|
+
}
|
|
2012
|
+
if (base.isArray(tests)) {
|
|
2013
|
+
var _tests = tests.map(function (test) {
|
|
2014
|
+
var _test = test;
|
|
2015
|
+
if (base.isArray(test)) {
|
|
2016
|
+
if (test.length == 2) {
|
|
2017
|
+
_test = new Test(test[0], test[1]);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
return _test;
|
|
2021
|
+
}).map(function (test, i) {
|
|
2022
|
+
return _this._runSingle(test, onProgress, i);
|
|
2023
|
+
});
|
|
2024
|
+
Promise.all(_tests).then(function (_) {
|
|
2025
|
+
return res(_this.result);
|
|
2026
|
+
})["catch"](function (ex) {
|
|
2027
|
+
_this._errors.push({
|
|
2028
|
+
err: new TestException({
|
|
2029
|
+
message: "not all tests succeeded. check errors.",
|
|
2030
|
+
code: 1503,
|
|
2031
|
+
status: "partial-finished",
|
|
2032
|
+
innerException: ex
|
|
2033
|
+
})
|
|
2034
|
+
});
|
|
2035
|
+
res(_this.result);
|
|
2036
|
+
});
|
|
2037
|
+
} else {
|
|
2038
|
+
_this._errors.push({
|
|
2039
|
+
err: new TestException({
|
|
2040
|
+
message: "invalid tests. expected array or a single test.",
|
|
2041
|
+
code: 1502,
|
|
2042
|
+
status: "invalid-tests"
|
|
2043
|
+
})
|
|
2044
|
+
});
|
|
2045
|
+
res(_this.result);
|
|
2046
|
+
}
|
|
2047
|
+
} else {
|
|
2048
|
+
_this._errors.push({
|
|
2049
|
+
err: new TestException({
|
|
2050
|
+
message: "no tests given to be ran.",
|
|
2051
|
+
code: 1501,
|
|
2052
|
+
status: "no-tests"
|
|
2053
|
+
})
|
|
2054
|
+
});
|
|
2055
|
+
res(_this.result);
|
|
2056
|
+
}
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
}, {
|
|
2060
|
+
key: "_getTime",
|
|
2061
|
+
value: function _getTime(time) {
|
|
2062
|
+
return "".concat(time / 1000, " sec");
|
|
2063
|
+
}
|
|
2064
|
+
}, {
|
|
2065
|
+
key: "report",
|
|
2066
|
+
value: function report(detailed) {
|
|
2067
|
+
var _this2 = this;
|
|
2068
|
+
var time = 0;
|
|
2069
|
+
console.log("Finished.\n");
|
|
2070
|
+
var _loop = function _loop() {
|
|
2071
|
+
var testResult = _this2._results[i];
|
|
2072
|
+
var t = "(".concat(_this2._getTime(testResult.time), ")");
|
|
2073
|
+
if (detailed) {
|
|
2074
|
+
var message = "\n" + (i + 1) + ". ";
|
|
2075
|
+
var err = base.isObject(testResult.err) ? testResult.err.toString().split("\n") : [];
|
|
2076
|
+
err = err.map(function (msg, i) {
|
|
2077
|
+
return "\t".concat(i == err.length - 1 ? "".concat(fgYellow) : "".concat(fgGray, "error ").concat(testResult.err.code, ": ")).concat(msg).concat(reset);
|
|
2078
|
+
}).join("\n");
|
|
2079
|
+
if (base.isObject(testResult.err)) {
|
|
2080
|
+
if (!testResult.expected) {
|
|
2081
|
+
message += "".concat(bright).concat(fgWhite).concat(testResult.test, ": ").concat(fgYellow, "faulted").concat(reset, " ").concat(t);
|
|
2082
|
+
message += "\n";
|
|
2083
|
+
message += "".concat(fgGray).concat(err, " ").concat(reset);
|
|
2084
|
+
} else {
|
|
2085
|
+
message += "".concat(bright).concat(fgWhite).concat(testResult.test, ": ").concat(fgRed, "failed").concat(reset, " ").concat(t);
|
|
2086
|
+
message += "\n";
|
|
2087
|
+
message += "".concat(fgGray).concat(err, " ").concat(reset);
|
|
2088
|
+
}
|
|
2089
|
+
} else if (!testResult.expected) {
|
|
2090
|
+
message += "".concat(bright).concat(fgWhite).concat(testResult.test, ": ").concat(fgMagenta, "expect not used").concat(reset, " ").concat(t);
|
|
2091
|
+
if (testResult.err) {
|
|
2092
|
+
message += "\n";
|
|
2093
|
+
message += "".concat(fgGray).concat(err, " ").concat(reset);
|
|
2094
|
+
}
|
|
2095
|
+
} else if (testResult.success) {
|
|
2096
|
+
message += "".concat(fgWhite).concat(testResult.test, ": ").concat(fgGreen, "passed").concat(reset, " ").concat(t);
|
|
2097
|
+
} else {
|
|
2098
|
+
message += "".concat(bright).concat(fgWhite).concat(testResult.test, ": ").concat(fgRed, "failed").concat(reset, " ").concat(t);
|
|
2099
|
+
message += "\n";
|
|
2100
|
+
message += "".concat(fgGray).concat(err, " ").concat(reset);
|
|
2101
|
+
}
|
|
2102
|
+
console.log(message);
|
|
2103
|
+
}
|
|
2104
|
+
time += testResult.time;
|
|
2105
|
+
};
|
|
2106
|
+
for (var i = 0; i < this._results.length; i++) {
|
|
2107
|
+
_loop();
|
|
2108
|
+
}
|
|
2109
|
+
if (detailed && this._errors.length) {
|
|
2110
|
+
console.log("Errors:");
|
|
2111
|
+
var _iterator = _createForOfIteratorHelper(this._errors),
|
|
2112
|
+
_step;
|
|
2113
|
+
try {
|
|
2114
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2115
|
+
var error = _step.value;
|
|
2116
|
+
if (error.index !== undefined) {
|
|
2117
|
+
console.log("".concat(error.index, ". ").concat(error.test, ": ").concat(error.err.innerException.toString()));
|
|
2118
|
+
} else {
|
|
2119
|
+
console.log("".concat(error.err.toString()));
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
} catch (err) {
|
|
2123
|
+
_iterator.e(err);
|
|
2124
|
+
} finally {
|
|
2125
|
+
_iterator.f();
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
var text = (detailed ? "\n" : "") + "".concat(bright, "Number of tests: ").concat(reset).concat(this._results.length) + "\n" + "".concat(bright, "Total Time: ").concat(reset).concat(time / 1000, " sec") + "\n\n" + (this._passed > 0 ? "".concat(fgGreen, " ").concat(this._passed, " test(s) passed").concat(reset) : "0 tests passed".concat(reset)) + ", " + (this._failed > 0 ? "".concat(fgRed).concat(this._failed, " test(s) failed").concat(reset) : "0 tests failed".concat(reset)) + (this._faulted > 0 ? ", ".concat(fgYellow).concat(this._faulted, " test(s) faulted").concat(reset) : "") + (this._unknown > 0 ? ", ".concat(fgMagenta).concat(this._unknown, " test(s) are unknown").concat(reset) : "") + "\n";
|
|
2129
|
+
console.log(text);
|
|
2130
|
+
}
|
|
2131
|
+
}, {
|
|
2132
|
+
key: "log",
|
|
2133
|
+
value: function log(filename) {
|
|
2134
|
+
var content = JSON.stringify({
|
|
2135
|
+
results: this._results,
|
|
2136
|
+
errors: this._errors
|
|
2137
|
+
}, null, "\t");
|
|
2138
|
+
if (filename == null) {
|
|
2139
|
+
var d = new Date();
|
|
2140
|
+
var year = d.getFullYear().toString().padStart(4, "0");
|
|
2141
|
+
var month = (d.getMonth() + 1).toString().padStart(2, "0");
|
|
2142
|
+
var day = d.getDate().toString().padStart(2, "0");
|
|
2143
|
+
var hours = d.getHours().toString().padStart(2, "0");
|
|
2144
|
+
var minutes = d.getMinutes().toString().padStart(2, "0");
|
|
2145
|
+
var seconds = d.getSeconds().toString().padStart(2, "0");
|
|
2146
|
+
filename = "test-".concat(year, "-").concat(month, "-").concat(day, "-").concat(hours).concat(minutes).concat(seconds, ".json");
|
|
2147
|
+
}
|
|
2148
|
+
var filepath = path.join(process.cwd(), filename);
|
|
2149
|
+
try {
|
|
2150
|
+
fs.writeFileSync(filepath, content);
|
|
2151
|
+
console.log("tests outcome wrote in ".concat(filename, "."));
|
|
2152
|
+
} catch (ex) {
|
|
2153
|
+
console.log("writing tests' report failed.\n" + ex);
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
}, {
|
|
2157
|
+
key: "test",
|
|
2158
|
+
value: function () {
|
|
2159
|
+
var _test2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2160
|
+
var _ref;
|
|
2161
|
+
var lastArg,
|
|
2162
|
+
detailed,
|
|
2163
|
+
_tests,
|
|
2164
|
+
i,
|
|
2165
|
+
t,
|
|
2166
|
+
result,
|
|
2167
|
+
_args2 = arguments;
|
|
2168
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2169
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2170
|
+
case 0:
|
|
2171
|
+
lastArg = (_ref = _args2.length - 1, _ref < 0 || _args2.length <= _ref ? undefined : _args2[_ref]);
|
|
2172
|
+
detailed = _args2.length && base.isBool(lastArg) ? lastArg : false;
|
|
2173
|
+
_tests = [];
|
|
2174
|
+
for (i = 0; i < _args2.length; i++) {
|
|
2175
|
+
t = i < 0 || _args2.length <= i ? undefined : _args2[i];
|
|
2176
|
+
if (i != _args2.length - 1 || !base.isBool(t)) {
|
|
2177
|
+
if (base.isIterable(t)) {
|
|
2178
|
+
_tests = [].concat(_toConsumableArray(_tests), _toConsumableArray(t));
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
_context2.next = 6;
|
|
2183
|
+
return this.run(_tests);
|
|
2184
|
+
case 6:
|
|
2185
|
+
result = _context2.sent;
|
|
2186
|
+
this.report(detailed || result.failed > 0);
|
|
2187
|
+
return _context2.abrupt("return", {
|
|
2188
|
+
runner: this,
|
|
2189
|
+
result: result
|
|
2190
|
+
});
|
|
2191
|
+
case 9:
|
|
2192
|
+
case "end":
|
|
2193
|
+
return _context2.stop();
|
|
2194
|
+
}
|
|
2195
|
+
}, _callee2, this);
|
|
2196
|
+
}));
|
|
2197
|
+
function test() {
|
|
2198
|
+
return _test2.apply(this, arguments);
|
|
2199
|
+
}
|
|
2200
|
+
return test;
|
|
2201
|
+
}()
|
|
2202
|
+
}], [{
|
|
2203
|
+
key: "start",
|
|
2204
|
+
value: function start() {
|
|
2205
|
+
var tr = new TestRunner();
|
|
2206
|
+
return tr.test.apply(tr, arguments);
|
|
2207
|
+
}
|
|
2208
|
+
}]);
|
|
2209
|
+
}();
|
|
2210
|
+
|
|
1568
2211
|
exports.Expect = Expect;
|
|
1569
2212
|
exports.Test = Test;
|
|
1570
2213
|
exports.TestException = TestException;
|