@locustjs/test 1.5.0 → 1.6.0
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/.babelrc +3 -0
- package/README.md +143 -24
- package/index.cjs.js +1649 -1150
- package/index.esm.js +358 -274
- package/package.json +6 -1
- package/tests/index.js +7 -1
package/index.cjs.js
CHANGED
|
@@ -1,1234 +1,1733 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
code: 1000,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return this.toBeGt(value);
|
|
38
|
-
}
|
|
39
|
-
toBeGte(value) {
|
|
40
|
-
this._expected = true;
|
|
41
|
-
if (this.value < value) {
|
|
42
|
-
throw new TestException({
|
|
43
|
-
message: `${this.value} is not greater than or equal to ${value}`,
|
|
44
|
-
code: 1002,
|
|
45
|
-
status: "lt"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
toBeGreaterThanOrEqualTo(value) {
|
|
51
|
-
return this.toBeGte(value);
|
|
52
|
-
}
|
|
53
|
-
toBeLt(value) {
|
|
54
|
-
this._expected = true;
|
|
55
|
-
if (this.value >= value) {
|
|
56
|
-
throw new TestException({
|
|
57
|
-
message: `${this.value} is not less than ${value}`,
|
|
58
|
-
code: 1003,
|
|
59
|
-
status: "gte"
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
toBeLowerThan(value) {
|
|
65
|
-
return this.toBeLt(value);
|
|
66
|
-
}
|
|
67
|
-
toBeLte(value) {
|
|
68
|
-
this._expected = true;
|
|
69
|
-
if (this.value > value) {
|
|
70
|
-
throw new TestException({
|
|
71
|
-
message: `${this.value} is not less than or equal to ${value}`,
|
|
72
|
-
code: 1004,
|
|
73
|
-
status: "gt"
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
toBeLowerThanOrEqualTo(value) {
|
|
79
|
-
return this.toBeLte(value);
|
|
80
|
-
}
|
|
81
|
-
toBeBetween(n, m) {
|
|
82
|
-
this._expected = true;
|
|
83
|
-
if (!(this.value >= n && this.value < m)) {
|
|
84
|
-
throw new TestException({
|
|
85
|
-
message: `${this.value} is not between ${n} and ${m}`,
|
|
86
|
-
code: 1024,
|
|
87
|
-
status: "between"
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
toBeOfType(type) {
|
|
93
|
-
this._expected = true;
|
|
94
|
-
if (typeof this.value !== type) {
|
|
95
|
-
throw new TestException({
|
|
96
|
-
message: `${this.value} is not of type ${type}`,
|
|
97
|
-
code: 1025,
|
|
98
|
-
status: "of-type"
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
toBeString() {
|
|
104
|
-
this._expected = true;
|
|
105
|
-
if (!isString(this.value)) {
|
|
106
|
-
throw new TestException({
|
|
107
|
-
message: `${this.value} is not string`,
|
|
108
|
-
code: 1026,
|
|
109
|
-
status: "is-string"
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
toBeSomeString() {
|
|
115
|
-
this._expected = true;
|
|
116
|
-
if (!isSomeString(this.value)) {
|
|
117
|
-
throw new TestException({
|
|
118
|
-
message: `${this.value} is not some string`,
|
|
119
|
-
code: 1027,
|
|
120
|
-
status: "is-some-string"
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
toBeNumber() {
|
|
126
|
-
this._expected = true;
|
|
127
|
-
if (!isNumber(this.value)) {
|
|
128
|
-
throw new TestException({
|
|
129
|
-
message: `${this.value} is not number`,
|
|
130
|
-
code: 1028,
|
|
131
|
-
status: "is-number"
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
toBeDate() {
|
|
137
|
-
this._expected = true;
|
|
138
|
-
if (!isDate(this.value)) {
|
|
139
|
-
throw new TestException({
|
|
140
|
-
message: `${this.value} is not date`,
|
|
141
|
-
code: 1029,
|
|
142
|
-
status: "is-date"
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
toBeBool() {
|
|
148
|
-
this._expected = true;
|
|
149
|
-
if (!isBool(this.value)) {
|
|
150
|
-
throw new TestException({
|
|
151
|
-
message: `${this.value} is not bool`,
|
|
152
|
-
code: 1030,
|
|
153
|
-
status: "is-bool"
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return this;
|
|
157
|
-
}
|
|
158
|
-
toBeBasicType() {
|
|
159
|
-
this._expected = true;
|
|
160
|
-
if (!isBasic(this.value)) {
|
|
161
|
-
throw new TestException({
|
|
162
|
-
message: `${this.value} is not basic type`,
|
|
163
|
-
code: 1031,
|
|
164
|
-
status: "is-basic-type"
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
return this;
|
|
168
|
-
}
|
|
169
|
-
toBePrimitive() {
|
|
170
|
-
this._expected = true;
|
|
171
|
-
if (!isPrimitive(this.value)) {
|
|
172
|
-
throw new TestException({
|
|
173
|
-
message: `${this.value} is not primitive type`,
|
|
174
|
-
code: 1032,
|
|
175
|
-
status: "is-primitive"
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
|
-
toBeEmpty() {
|
|
181
|
-
this._expected = true;
|
|
182
|
-
if (!isEmpty(this.value)) {
|
|
183
|
-
throw new TestException({
|
|
184
|
-
message: `${this.value} is not empty`,
|
|
185
|
-
code: 1033,
|
|
186
|
-
status: "is-empty"
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
return this;
|
|
190
|
-
}
|
|
191
|
-
toBeObject() {
|
|
192
|
-
this._expected = true;
|
|
193
|
-
if (!isObject(this.value)) {
|
|
194
|
-
throw new TestException({
|
|
195
|
-
message: `${this.value} is not object`,
|
|
196
|
-
code: 1034,
|
|
197
|
-
status: "is-object"
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
toBeSomeObject() {
|
|
203
|
-
this._expected = true;
|
|
204
|
-
if (!isSomeObject(this.value)) {
|
|
205
|
-
throw new TestException({
|
|
206
|
-
message: `${this.value} is not some object`,
|
|
207
|
-
code: 1035,
|
|
208
|
-
status: "is-some-object"
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
return this;
|
|
212
|
-
}
|
|
213
|
-
toBeFunction() {
|
|
214
|
-
this._expected = true;
|
|
215
|
-
if (!isFunction(this.value)) {
|
|
216
|
-
throw new TestException({
|
|
217
|
-
message: `${this.value} is not function`,
|
|
218
|
-
code: 1036,
|
|
219
|
-
status: "is-function"
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return this;
|
|
223
|
-
}
|
|
224
|
-
toBeNumeric() {
|
|
225
|
-
this._expected = true;
|
|
226
|
-
if (!isNumeric(this.value)) {
|
|
227
|
-
throw new TestException({
|
|
228
|
-
message: `${this.value} is not numeric`,
|
|
229
|
-
code: 1037,
|
|
230
|
-
status: "is-numeric"
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
return this;
|
|
234
|
-
}
|
|
235
|
-
toBeArray() {
|
|
236
|
-
this._expected = true;
|
|
237
|
-
if (!isArray(this.value)) {
|
|
238
|
-
throw new TestException({
|
|
239
|
-
message: `${this.value} is not array`,
|
|
240
|
-
code: 1038,
|
|
241
|
-
status: "is-array"
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
toBeSomeArray() {
|
|
247
|
-
this._expected = true;
|
|
248
|
-
if (!isSomeArray(this.value)) {
|
|
249
|
-
throw new TestException({
|
|
250
|
-
message: `${this.value} is not some array`,
|
|
251
|
-
code: 1039,
|
|
252
|
-
status: "is-some-array"
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
return this;
|
|
256
|
-
}
|
|
257
|
-
toBeIterable() {
|
|
258
|
-
this._expected = true;
|
|
259
|
-
if (!isIterable(this.value)) {
|
|
260
|
-
throw new TestException({
|
|
261
|
-
message: `${this.value} is not iterable`,
|
|
262
|
-
code: 1040,
|
|
263
|
-
status: "is-iterable"
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
return this;
|
|
267
|
-
}
|
|
268
|
-
toBeSubClassOf(type) {
|
|
269
|
-
this._expected = true;
|
|
270
|
-
if (!isSubClassOf(this.value, type)) {
|
|
271
|
-
throw new TestException({
|
|
272
|
-
message: `${this.value} is not subclass of ${type}`,
|
|
273
|
-
code: 1041,
|
|
274
|
-
status: "is-subclass-of"
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
return this;
|
|
278
|
-
}
|
|
279
|
-
toBeInstanceOf(type) {
|
|
280
|
-
this._expected = true;
|
|
281
|
-
if (!(this.value instanceof type)) {
|
|
282
|
-
throw new TestException({
|
|
283
|
-
message: `${this.value} is not instance of ${type}`,
|
|
284
|
-
code: 1042,
|
|
285
|
-
status: "instanceof"
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
return this;
|
|
289
|
-
}
|
|
290
|
-
toMatch(pattern, flags) {
|
|
291
|
-
this._expected = true;
|
|
292
|
-
const r = new RegExp(pattern, flags);
|
|
293
|
-
if (!r.test(this.value)) {
|
|
294
|
-
throw new TestException({
|
|
295
|
-
message: `${this.value} does not match ${pattern}`,
|
|
296
|
-
code: 1043,
|
|
297
|
-
status: "match"
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
return this;
|
|
301
|
-
}
|
|
302
|
-
notToBe(value) {
|
|
303
|
-
this._expected = true;
|
|
304
|
-
if (this.value === value) {
|
|
305
|
-
throw new TestException({
|
|
306
|
-
message: `${value} is equal to ${this.value}`,
|
|
307
|
-
code: 1005,
|
|
308
|
-
status: "eq"
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
return this;
|
|
312
|
-
}
|
|
313
|
-
toBeDefined() {
|
|
314
|
-
this._expected = true;
|
|
315
|
-
if (this.value === undefined) {
|
|
316
|
-
throw new TestException({
|
|
317
|
-
message: `value is undefined`,
|
|
318
|
-
code: 1006,
|
|
319
|
-
status: "undefined"
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
return this;
|
|
323
|
-
}
|
|
324
|
-
toBeUndefined() {
|
|
325
|
-
this._expected = true;
|
|
326
|
-
if (this.value !== undefined) {
|
|
327
|
-
throw new TestException({
|
|
328
|
-
message: `value is defined`,
|
|
329
|
-
code: 1007,
|
|
330
|
-
status: "defined"
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
return this;
|
|
334
|
-
}
|
|
335
|
-
toBeNull() {
|
|
336
|
-
this._expected = true;
|
|
337
|
-
if (this.value !== null) {
|
|
338
|
-
throw new TestException({
|
|
339
|
-
message: `value is not null`,
|
|
340
|
-
code: 1008,
|
|
341
|
-
status: "not-null"
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
return this;
|
|
345
|
-
}
|
|
346
|
-
notToBeNull() {
|
|
347
|
-
this._expected = true;
|
|
348
|
-
if (this.value === null) {
|
|
349
|
-
throw new TestException({
|
|
350
|
-
message: `value is null`,
|
|
351
|
-
code: 1009,
|
|
352
|
-
status: "null"
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
return this;
|
|
356
|
-
}
|
|
357
|
-
toBeNullOrUndefined() {
|
|
358
|
-
this._expected = true;
|
|
359
|
-
if (this.value == null) {} else {
|
|
360
|
-
throw new TestException({
|
|
361
|
-
message: `value is not null/undefined`,
|
|
362
|
-
code: 1010,
|
|
363
|
-
status: "not-null-or-undefined"
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
return this;
|
|
367
|
-
}
|
|
368
|
-
notToBeNullOrUndefined() {
|
|
369
|
-
this._expected = true;
|
|
370
|
-
if (this.value == null) {
|
|
371
|
-
throw new TestException({
|
|
372
|
-
message: `value is null/undefined`,
|
|
373
|
-
code: 1011,
|
|
374
|
-
status: "null-or-undefined"
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
return this;
|
|
378
|
-
}
|
|
379
|
-
notToBeBetween(n, m) {
|
|
380
|
-
this._expected = true;
|
|
381
|
-
if (this.value >= n && this.value < m) {
|
|
382
|
-
throw new TestException({
|
|
383
|
-
message: `${this.value} is between ${n} and ${m}`,
|
|
384
|
-
code: 1044,
|
|
385
|
-
status: "not-between"
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
return this;
|
|
389
|
-
}
|
|
390
|
-
notToBeOfType(type) {
|
|
391
|
-
this._expected = true;
|
|
392
|
-
if (typeof this.value === type) {
|
|
393
|
-
throw new TestException({
|
|
394
|
-
message: `${this.value} is of type ${type}`,
|
|
395
|
-
code: 1045,
|
|
396
|
-
status: "not-oftype"
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
return this;
|
|
400
|
-
}
|
|
401
|
-
notToBeString() {
|
|
402
|
-
this._expected = true;
|
|
403
|
-
if (isString(this.value)) {
|
|
404
|
-
throw new TestException({
|
|
405
|
-
message: `${this.value} is string`,
|
|
406
|
-
code: 1046,
|
|
407
|
-
status: "not-is-string"
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
return this;
|
|
411
|
-
}
|
|
412
|
-
notToBeSomeString() {
|
|
413
|
-
this._expected = true;
|
|
414
|
-
if (isSomeString(this.value)) {
|
|
415
|
-
throw new TestException({
|
|
416
|
-
message: `${this.value} is some string`,
|
|
417
|
-
code: 1047,
|
|
418
|
-
status: "not-is-some-string"
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
return this;
|
|
422
|
-
}
|
|
423
|
-
notToBeNumber() {
|
|
424
|
-
this._expected = true;
|
|
425
|
-
if (isNumber(this.value)) {
|
|
426
|
-
throw new TestException({
|
|
427
|
-
message: `${this.value} is number`,
|
|
428
|
-
code: 1048,
|
|
429
|
-
status: "not-is-number"
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
return this;
|
|
433
|
-
}
|
|
434
|
-
notToBeDate() {
|
|
435
|
-
this._expected = true;
|
|
436
|
-
if (isDate(this.value)) {
|
|
437
|
-
throw new TestException({
|
|
438
|
-
message: `${this.value} is date`,
|
|
439
|
-
code: 1049,
|
|
440
|
-
status: "not-is-date"
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
return this;
|
|
444
|
-
}
|
|
445
|
-
notToBeBool() {
|
|
446
|
-
this._expected = true;
|
|
447
|
-
if (isBool(this.value)) {
|
|
448
|
-
throw new TestException({
|
|
449
|
-
message: `${this.value} is bool`,
|
|
450
|
-
code: 1050,
|
|
451
|
-
status: "not-is-bool"
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
return this;
|
|
455
|
-
}
|
|
456
|
-
notToBeBasicType() {
|
|
457
|
-
this._expected = true;
|
|
458
|
-
if (isBasic(this.value)) {
|
|
459
|
-
throw new TestException({
|
|
460
|
-
message: `${this.value} is basic type`,
|
|
461
|
-
code: 1051,
|
|
462
|
-
status: "not-is-basic-type"
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
return this;
|
|
466
|
-
}
|
|
467
|
-
notToBePrimitive() {
|
|
468
|
-
this._expected = true;
|
|
469
|
-
if (isPrimitive(this.value)) {
|
|
470
|
-
throw new TestException({
|
|
471
|
-
message: `${this.value} is primitive type`,
|
|
472
|
-
code: 1052,
|
|
473
|
-
status: "not-is-primitive"
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
return this;
|
|
477
|
-
}
|
|
478
|
-
notToBeEmpty() {
|
|
479
|
-
this._expected = true;
|
|
480
|
-
if (isEmpty(this.value)) {
|
|
481
|
-
throw new TestException({
|
|
482
|
-
message: `${this.value} is empty`,
|
|
483
|
-
code: 1053,
|
|
484
|
-
status: "not-is-empty"
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
return this;
|
|
488
|
-
}
|
|
489
|
-
notToBeObject() {
|
|
490
|
-
this._expected = true;
|
|
491
|
-
if (isObject(this.value)) {
|
|
492
|
-
throw new TestException({
|
|
493
|
-
message: `${this.value} is object`,
|
|
494
|
-
code: 1054,
|
|
495
|
-
status: "not-is-object"
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
return this;
|
|
499
|
-
}
|
|
500
|
-
notToBeSomeObject() {
|
|
501
|
-
this._expected = true;
|
|
502
|
-
if (isSomeObject(this.value)) {
|
|
503
|
-
throw new TestException({
|
|
504
|
-
message: `${this.value} is some object`,
|
|
505
|
-
code: 1055,
|
|
506
|
-
status: "not-is-some-object"
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
return this;
|
|
510
|
-
}
|
|
511
|
-
notToBeFunction() {
|
|
512
|
-
this._expected = true;
|
|
513
|
-
if (isFunction(this.value)) {
|
|
514
|
-
throw new TestException({
|
|
515
|
-
message: `${this.value} is function`,
|
|
516
|
-
code: 1056,
|
|
517
|
-
status: "not-is-function"
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
return this;
|
|
521
|
-
}
|
|
522
|
-
notToBeNumeric() {
|
|
523
|
-
this._expected = true;
|
|
524
|
-
if (isNumeric(this.value)) {
|
|
525
|
-
throw new TestException({
|
|
526
|
-
message: `${this.value} is numeric`,
|
|
527
|
-
code: 1057,
|
|
528
|
-
status: "not-is-numeric"
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
return this;
|
|
532
|
-
}
|
|
533
|
-
notToBeArray() {
|
|
534
|
-
this._expected = true;
|
|
535
|
-
if (isArray(this.value)) {
|
|
536
|
-
throw new TestException({
|
|
537
|
-
message: `${this.value} is array`,
|
|
538
|
-
code: 1058,
|
|
539
|
-
status: "not-is-array"
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
return this;
|
|
543
|
-
}
|
|
544
|
-
toBeEmptyArray() {
|
|
545
|
-
this._expected = true;
|
|
546
|
-
if (isSomeArray(this.value)) {
|
|
547
|
-
throw new TestException({
|
|
548
|
-
message: `${this.value} is some array`,
|
|
549
|
-
code: 1059,
|
|
550
|
-
status: "to-be-empty-array"
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
return this;
|
|
554
|
-
}
|
|
555
|
-
notToBeIterable() {
|
|
556
|
-
this._expected = true;
|
|
557
|
-
if (isIterable(this.value)) {
|
|
558
|
-
throw new TestException({
|
|
559
|
-
message: `${this.value} is iterable`,
|
|
560
|
-
code: 1060,
|
|
561
|
-
status: "not-iterable"
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
return this;
|
|
565
|
-
}
|
|
566
|
-
notToBeSubClassOf(type) {
|
|
567
|
-
this._expected = true;
|
|
568
|
-
if (isSubClassOf(this.value, type)) {
|
|
569
|
-
throw new TestException({
|
|
570
|
-
message: `${this.value} is subclass of ${type}`,
|
|
571
|
-
code: 1061,
|
|
572
|
-
status: "not-subclassof"
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
return this;
|
|
576
|
-
}
|
|
577
|
-
notToBeInstanceOf(type) {
|
|
578
|
-
this._expected = true;
|
|
579
|
-
if (this.value instanceof type) {
|
|
580
|
-
throw new TestException({
|
|
581
|
-
message: `${this.value} is instance of ${type}`,
|
|
582
|
-
code: 1062,
|
|
583
|
-
status: "not-instanceof"
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
return this;
|
|
587
|
-
}
|
|
588
|
-
doesNotMatch(pattern, flags) {
|
|
589
|
-
this._expected = true;
|
|
590
|
-
const r = new RegExp(pattern, flags);
|
|
591
|
-
if (r.test(this.value)) {
|
|
592
|
-
throw new TestException({
|
|
593
|
-
message: `${this.value} matches ${pattern}`,
|
|
594
|
-
code: 1063,
|
|
595
|
-
status: "not-match"
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
return this;
|
|
599
|
-
}
|
|
600
|
-
toBeValid(fnValidation) {
|
|
601
|
-
this._expected = true;
|
|
602
|
-
if (!isFunction(fnValidation)) {
|
|
603
|
-
throw new TestException({
|
|
604
|
-
message: `fnValidation is not function`,
|
|
605
|
-
code: 1064,
|
|
606
|
-
status: "to-be-valid"
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
if (!fnValidation(this.value)) {
|
|
610
|
-
throw new TestException({
|
|
611
|
-
message: `${this.value} is not valid`,
|
|
612
|
-
code: 1065,
|
|
613
|
-
status: "to-be-valid"
|
|
614
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.TestException = exports.Test = exports.Expect = void 0;
|
|
7
|
+
var _base = require("@locustjs/base");
|
|
8
|
+
var _exception = require("@locustjs/exception");
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
17
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
20
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
22
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
23
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
27
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28
|
+
function _callSuper(_this, derived, args) {
|
|
29
|
+
function isNativeReflectConstruct() {
|
|
30
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
31
|
+
if (Reflect.construct.sham) return false;
|
|
32
|
+
if (typeof Proxy === "function") return true;
|
|
33
|
+
try {
|
|
34
|
+
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return false;
|
|
615
37
|
}
|
|
616
|
-
return this;
|
|
617
38
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
39
|
+
derived = _getPrototypeOf(derived);
|
|
40
|
+
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
41
|
+
}
|
|
42
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
43
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
46
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
47
|
+
var TestException = exports.TestException = /*#__PURE__*/function (_Exception) {
|
|
48
|
+
function TestException() {
|
|
49
|
+
_classCallCheck(this, TestException);
|
|
50
|
+
return _callSuper(this, TestException, arguments);
|
|
51
|
+
}
|
|
52
|
+
_inherits(TestException, _Exception);
|
|
53
|
+
return _createClass(TestException);
|
|
54
|
+
}(_exception.Exception);
|
|
55
|
+
var Expect = exports.Expect = /*#__PURE__*/function () {
|
|
56
|
+
function Expect(value) {
|
|
57
|
+
_classCallCheck(this, Expect);
|
|
58
|
+
this.value = value;
|
|
59
|
+
this._expected = false;
|
|
635
60
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
61
|
+
return _createClass(Expect, [{
|
|
62
|
+
key: "expected",
|
|
63
|
+
get: function get() {
|
|
64
|
+
return this._expected;
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "toBe",
|
|
68
|
+
value: function toBe(value) {
|
|
69
|
+
this._expected = true;
|
|
70
|
+
if (this.value === value) {} else {
|
|
71
|
+
throw new TestException({
|
|
72
|
+
message: "".concat(this.value, " is not equal to ").concat(value),
|
|
73
|
+
code: 1000,
|
|
74
|
+
status: "not-eq"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "notToBe",
|
|
81
|
+
value: function notToBe(value) {
|
|
82
|
+
this._expected = true;
|
|
83
|
+
if (this.value === value) {
|
|
84
|
+
throw new TestException({
|
|
85
|
+
message: "".concat(value, " is equal to ").concat(this.value),
|
|
86
|
+
code: 1005,
|
|
87
|
+
status: "eq"
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "toBeGt",
|
|
94
|
+
value: function toBeGt(value) {
|
|
95
|
+
this._expected = true;
|
|
96
|
+
if (this.value <= value) {
|
|
97
|
+
throw new TestException({
|
|
98
|
+
message: "".concat(this.value, " is not greater than ").concat(value),
|
|
99
|
+
code: 1001,
|
|
100
|
+
status: "lte"
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "toBeGreaterThan",
|
|
107
|
+
value: function toBeGreaterThan(value) {
|
|
108
|
+
return this.toBeGt(value);
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "toBeGte",
|
|
112
|
+
value: function toBeGte(value) {
|
|
113
|
+
this._expected = true;
|
|
114
|
+
if (this.value < value) {
|
|
115
|
+
throw new TestException({
|
|
116
|
+
message: "".concat(this.value, " is not greater than or equal to ").concat(value),
|
|
117
|
+
code: 1002,
|
|
118
|
+
status: "lt"
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "toBeGreaterThanOrEqualTo",
|
|
125
|
+
value: function toBeGreaterThanOrEqualTo(value) {
|
|
126
|
+
return this.toBeGte(value);
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "toBeLt",
|
|
130
|
+
value: function toBeLt(value) {
|
|
131
|
+
this._expected = true;
|
|
132
|
+
if (this.value >= value) {
|
|
133
|
+
throw new TestException({
|
|
134
|
+
message: "".concat(this.value, " is not less than ").concat(value),
|
|
135
|
+
code: 1003,
|
|
136
|
+
status: "gte"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "toBeLowerThan",
|
|
143
|
+
value: function toBeLowerThan(value) {
|
|
144
|
+
return this.toBeLt(value);
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "toBeLte",
|
|
148
|
+
value: function toBeLte(value) {
|
|
149
|
+
this._expected = true;
|
|
150
|
+
if (this.value > value) {
|
|
151
|
+
throw new TestException({
|
|
152
|
+
message: "".concat(this.value, " is not less than or equal to ").concat(value),
|
|
153
|
+
code: 1004,
|
|
154
|
+
status: "gt"
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
}, {
|
|
160
|
+
key: "toBeLowerThanOrEqualTo",
|
|
161
|
+
value: function toBeLowerThanOrEqualTo(value) {
|
|
162
|
+
return this.toBeLte(value);
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "toBeBetween",
|
|
166
|
+
value: function toBeBetween(n, m) {
|
|
167
|
+
this._expected = true;
|
|
168
|
+
if (!(this.value >= n && this.value < m)) {
|
|
169
|
+
throw new TestException({
|
|
170
|
+
message: "".concat(this.value, " is not between ").concat(n, " and ").concat(m),
|
|
171
|
+
code: 1024,
|
|
172
|
+
status: "between"
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return this;
|
|
176
|
+
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "notToBeBetween",
|
|
179
|
+
value: function notToBeBetween(n, m) {
|
|
180
|
+
this._expected = true;
|
|
181
|
+
if (this.value >= n && this.value < m) {
|
|
182
|
+
throw new TestException({
|
|
183
|
+
message: "".concat(this.value, " is between ").concat(n, " and ").concat(m),
|
|
184
|
+
code: 1044,
|
|
185
|
+
status: "not-between"
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "toBeOfType",
|
|
192
|
+
value: function toBeOfType(type) {
|
|
193
|
+
this._expected = true;
|
|
194
|
+
if (_typeof(this.value) !== type) {
|
|
195
|
+
throw new TestException({
|
|
196
|
+
message: "".concat(this.value, " is not of type ").concat(type),
|
|
197
|
+
code: 1025,
|
|
198
|
+
status: "of-type"
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "notToBeOfType",
|
|
205
|
+
value: function notToBeOfType(type) {
|
|
206
|
+
this._expected = true;
|
|
207
|
+
if (_typeof(this.value) === type) {
|
|
208
|
+
throw new TestException({
|
|
209
|
+
message: "".concat(this.value, " is of type ").concat(type),
|
|
210
|
+
code: 1045,
|
|
211
|
+
status: "not-oftype"
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "toBeString",
|
|
218
|
+
value: function toBeString() {
|
|
219
|
+
this._expected = true;
|
|
220
|
+
if (!(0, _base.isString)(this.value)) {
|
|
221
|
+
throw new TestException({
|
|
222
|
+
message: "".concat(this.value, " is not string"),
|
|
223
|
+
code: 1026,
|
|
224
|
+
status: "is-string"
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
}, {
|
|
230
|
+
key: "notToBeString",
|
|
231
|
+
value: function notToBeString() {
|
|
232
|
+
this._expected = true;
|
|
233
|
+
if ((0, _base.isString)(this.value)) {
|
|
234
|
+
throw new TestException({
|
|
235
|
+
message: "".concat(this.value, " is string"),
|
|
236
|
+
code: 1046,
|
|
237
|
+
status: "not-is-string"
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "toBeSomeString",
|
|
244
|
+
value: function toBeSomeString() {
|
|
245
|
+
this._expected = true;
|
|
246
|
+
if (!(0, _base.isSomeString)(this.value)) {
|
|
247
|
+
throw new TestException({
|
|
248
|
+
message: "".concat(this.value, " is not some string"),
|
|
249
|
+
code: 1027,
|
|
250
|
+
status: "is-some-string"
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "notToBeSomeString",
|
|
257
|
+
value: function notToBeSomeString() {
|
|
258
|
+
this._expected = true;
|
|
259
|
+
if ((0, _base.isSomeString)(this.value)) {
|
|
260
|
+
throw new TestException({
|
|
261
|
+
message: "".concat(this.value, " is some string"),
|
|
262
|
+
code: 1047,
|
|
263
|
+
status: "not-is-some-string"
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "toBeNumber",
|
|
270
|
+
value: function toBeNumber() {
|
|
271
|
+
this._expected = true;
|
|
272
|
+
if (!(0, _base.isNumber)(this.value)) {
|
|
273
|
+
throw new TestException({
|
|
274
|
+
message: "".concat(this.value, " is not number"),
|
|
275
|
+
code: 1028,
|
|
276
|
+
status: "is-number"
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
}, {
|
|
282
|
+
key: "notToBeNumber",
|
|
283
|
+
value: function notToBeNumber() {
|
|
284
|
+
this._expected = true;
|
|
285
|
+
if ((0, _base.isNumber)(this.value)) {
|
|
286
|
+
throw new TestException({
|
|
287
|
+
message: "".concat(this.value, " is number"),
|
|
288
|
+
code: 1048,
|
|
289
|
+
status: "not-is-number"
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return this;
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
key: "toBeDate",
|
|
296
|
+
value: function toBeDate() {
|
|
297
|
+
this._expected = true;
|
|
298
|
+
if (!(0, _base.isDate)(this.value)) {
|
|
299
|
+
throw new TestException({
|
|
300
|
+
message: "".concat(this.value, " is not date"),
|
|
301
|
+
code: 1029,
|
|
302
|
+
status: "is-date"
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
}, {
|
|
308
|
+
key: "notToBeDate",
|
|
309
|
+
value: function notToBeDate() {
|
|
310
|
+
this._expected = true;
|
|
311
|
+
if ((0, _base.isDate)(this.value)) {
|
|
312
|
+
throw new TestException({
|
|
313
|
+
message: "".concat(this.value, " is date"),
|
|
314
|
+
code: 1049,
|
|
315
|
+
status: "not-is-date"
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return this;
|
|
319
|
+
}
|
|
320
|
+
}, {
|
|
321
|
+
key: "toBeBool",
|
|
322
|
+
value: function toBeBool() {
|
|
323
|
+
this._expected = true;
|
|
324
|
+
if (!(0, _base.isBool)(this.value)) {
|
|
325
|
+
throw new TestException({
|
|
326
|
+
message: "".concat(this.value, " is not bool"),
|
|
327
|
+
code: 1030,
|
|
328
|
+
status: "is-bool"
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return this;
|
|
332
|
+
}
|
|
333
|
+
}, {
|
|
334
|
+
key: "notToBeBool",
|
|
335
|
+
value: function notToBeBool() {
|
|
336
|
+
this._expected = true;
|
|
337
|
+
if ((0, _base.isBool)(this.value)) {
|
|
338
|
+
throw new TestException({
|
|
339
|
+
message: "".concat(this.value, " is bool"),
|
|
340
|
+
code: 1050,
|
|
341
|
+
status: "not-is-bool"
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
return this;
|
|
345
|
+
}
|
|
346
|
+
}, {
|
|
347
|
+
key: "toBeBasicType",
|
|
348
|
+
value: function toBeBasicType() {
|
|
349
|
+
this._expected = true;
|
|
350
|
+
if (!(0, _base.isBasic)(this.value)) {
|
|
351
|
+
throw new TestException({
|
|
352
|
+
message: "".concat(this.value, " is not basic type"),
|
|
353
|
+
code: 1031,
|
|
354
|
+
status: "is-basic-type"
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return this;
|
|
358
|
+
}
|
|
359
|
+
}, {
|
|
360
|
+
key: "notToBeBasicType",
|
|
361
|
+
value: function notToBeBasicType() {
|
|
362
|
+
this._expected = true;
|
|
363
|
+
if ((0, _base.isBasic)(this.value)) {
|
|
364
|
+
throw new TestException({
|
|
365
|
+
message: "".concat(this.value, " is basic type"),
|
|
366
|
+
code: 1051,
|
|
367
|
+
status: "not-is-basic-type"
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
return this;
|
|
371
|
+
}
|
|
372
|
+
}, {
|
|
373
|
+
key: "toBePrimitive",
|
|
374
|
+
value: function toBePrimitive() {
|
|
375
|
+
this._expected = true;
|
|
376
|
+
if (!(0, _base.isPrimitive)(this.value)) {
|
|
377
|
+
throw new TestException({
|
|
378
|
+
message: "".concat(this.value, " is not primitive type"),
|
|
379
|
+
code: 1032,
|
|
380
|
+
status: "is-primitive"
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return this;
|
|
384
|
+
}
|
|
385
|
+
}, {
|
|
386
|
+
key: "notToBePrimitive",
|
|
387
|
+
value: function notToBePrimitive() {
|
|
388
|
+
this._expected = true;
|
|
389
|
+
if ((0, _base.isPrimitive)(this.value)) {
|
|
390
|
+
throw new TestException({
|
|
391
|
+
message: "".concat(this.value, " is primitive type"),
|
|
392
|
+
code: 1052,
|
|
393
|
+
status: "not-is-primitive"
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return this;
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "toBeEmpty",
|
|
400
|
+
value: function toBeEmpty() {
|
|
401
|
+
this._expected = true;
|
|
402
|
+
if (!(0, _base.isEmpty)(this.value)) {
|
|
403
|
+
throw new TestException({
|
|
404
|
+
message: "".concat(this.value, " is not empty"),
|
|
405
|
+
code: 1033,
|
|
406
|
+
status: "is-empty"
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
}, {
|
|
412
|
+
key: "notToBeEmpty",
|
|
413
|
+
value: function notToBeEmpty() {
|
|
414
|
+
this._expected = true;
|
|
415
|
+
if ((0, _base.isEmpty)(this.value)) {
|
|
416
|
+
throw new TestException({
|
|
417
|
+
message: "".concat(this.value, " is empty"),
|
|
418
|
+
code: 1053,
|
|
419
|
+
status: "not-is-empty"
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
}, {
|
|
425
|
+
key: "toBeObject",
|
|
426
|
+
value: function toBeObject() {
|
|
427
|
+
this._expected = true;
|
|
428
|
+
if (!(0, _base.isObject)(this.value)) {
|
|
429
|
+
throw new TestException({
|
|
430
|
+
message: "".concat(this.value, " is not object"),
|
|
431
|
+
code: 1034,
|
|
432
|
+
status: "is-object"
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
return this;
|
|
436
|
+
}
|
|
437
|
+
}, {
|
|
438
|
+
key: "notToBeObject",
|
|
439
|
+
value: function notToBeObject() {
|
|
440
|
+
this._expected = true;
|
|
441
|
+
if ((0, _base.isObject)(this.value)) {
|
|
442
|
+
throw new TestException({
|
|
443
|
+
message: "".concat(this.value, " is object"),
|
|
444
|
+
code: 1054,
|
|
445
|
+
status: "not-is-object"
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
return this;
|
|
449
|
+
}
|
|
450
|
+
}, {
|
|
451
|
+
key: "toBeSomeObject",
|
|
452
|
+
value: function toBeSomeObject() {
|
|
453
|
+
this._expected = true;
|
|
454
|
+
if (!(0, _base.isSomeObject)(this.value)) {
|
|
455
|
+
throw new TestException({
|
|
456
|
+
message: "".concat(this.value, " is not some object"),
|
|
457
|
+
code: 1035,
|
|
458
|
+
status: "is-some-object"
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return this;
|
|
462
|
+
}
|
|
463
|
+
}, {
|
|
464
|
+
key: "notToBeSomeObject",
|
|
465
|
+
value: function notToBeSomeObject() {
|
|
466
|
+
this._expected = true;
|
|
467
|
+
if ((0, _base.isSomeObject)(this.value)) {
|
|
468
|
+
throw new TestException({
|
|
469
|
+
message: "".concat(this.value, " is some object"),
|
|
470
|
+
code: 1055,
|
|
471
|
+
status: "not-is-some-object"
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return this;
|
|
475
|
+
}
|
|
476
|
+
}, {
|
|
477
|
+
key: "toBeFunction",
|
|
478
|
+
value: function toBeFunction() {
|
|
479
|
+
this._expected = true;
|
|
480
|
+
if (!(0, _base.isFunction)(this.value)) {
|
|
481
|
+
throw new TestException({
|
|
482
|
+
message: "".concat(this.value, " is not function"),
|
|
483
|
+
code: 1036,
|
|
484
|
+
status: "is-function"
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
}, {
|
|
490
|
+
key: "notToBeFunction",
|
|
491
|
+
value: function notToBeFunction() {
|
|
492
|
+
this._expected = true;
|
|
493
|
+
if ((0, _base.isFunction)(this.value)) {
|
|
494
|
+
throw new TestException({
|
|
495
|
+
message: "".concat(this.value, " is function"),
|
|
496
|
+
code: 1056,
|
|
497
|
+
status: "not-is-function"
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
return this;
|
|
501
|
+
}
|
|
502
|
+
}, {
|
|
503
|
+
key: "toBeNumeric",
|
|
504
|
+
value: function toBeNumeric() {
|
|
505
|
+
this._expected = true;
|
|
506
|
+
if (!(0, _base.isNumeric)(this.value)) {
|
|
507
|
+
throw new TestException({
|
|
508
|
+
message: "".concat(this.value, " is not numeric"),
|
|
509
|
+
code: 1037,
|
|
510
|
+
status: "is-numeric"
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
return this;
|
|
514
|
+
}
|
|
515
|
+
}, {
|
|
516
|
+
key: "notToBeNumeric",
|
|
517
|
+
value: function notToBeNumeric() {
|
|
518
|
+
this._expected = true;
|
|
519
|
+
if ((0, _base.isNumeric)(this.value)) {
|
|
520
|
+
throw new TestException({
|
|
521
|
+
message: "".concat(this.value, " is numeric"),
|
|
522
|
+
code: 1057,
|
|
523
|
+
status: "not-is-numeric"
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
return this;
|
|
527
|
+
}
|
|
528
|
+
}, {
|
|
529
|
+
key: "toBeArray",
|
|
530
|
+
value: function toBeArray() {
|
|
531
|
+
this._expected = true;
|
|
532
|
+
if (!(0, _base.isArray)(this.value)) {
|
|
533
|
+
throw new TestException({
|
|
534
|
+
message: "".concat(this.value, " is not array"),
|
|
535
|
+
code: 1038,
|
|
536
|
+
status: "is-array"
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
return this;
|
|
540
|
+
}
|
|
541
|
+
}, {
|
|
542
|
+
key: "notToBeArray",
|
|
543
|
+
value: function notToBeArray() {
|
|
544
|
+
this._expected = true;
|
|
545
|
+
if ((0, _base.isArray)(this.value)) {
|
|
546
|
+
throw new TestException({
|
|
547
|
+
message: "".concat(this.value, " is array"),
|
|
548
|
+
code: 1058,
|
|
549
|
+
status: "not-is-array"
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
return this;
|
|
553
|
+
}
|
|
554
|
+
}, {
|
|
555
|
+
key: "toBeSomeArray",
|
|
556
|
+
value: function toBeSomeArray() {
|
|
557
|
+
this._expected = true;
|
|
558
|
+
if (!(0, _base.isSomeArray)(this.value)) {
|
|
559
|
+
throw new TestException({
|
|
560
|
+
message: "".concat(this.value, " is not some array"),
|
|
561
|
+
code: 1039,
|
|
562
|
+
status: "is-some-array"
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
return this;
|
|
566
|
+
}
|
|
567
|
+
}, {
|
|
568
|
+
key: "notToBeSomeArray",
|
|
569
|
+
value: function notToBeSomeArray() {
|
|
570
|
+
this._expected = true;
|
|
571
|
+
if ((0, _base.isArray)(this.value)) {
|
|
572
|
+
throw new TestException({
|
|
573
|
+
message: "".concat(this.value, " is array"),
|
|
574
|
+
code: 1068,
|
|
575
|
+
status: "is-array"
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
if (this.value.length) {
|
|
579
|
+
throw new TestException({
|
|
580
|
+
message: "".concat(this.value, " is array"),
|
|
581
|
+
code: 1069,
|
|
582
|
+
status: "is-some-array"
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
return this;
|
|
586
|
+
}
|
|
587
|
+
}, {
|
|
588
|
+
key: "toBeIterable",
|
|
589
|
+
value: function toBeIterable() {
|
|
590
|
+
this._expected = true;
|
|
591
|
+
if (!(0, _base.isIterable)(this.value)) {
|
|
592
|
+
throw new TestException({
|
|
593
|
+
message: "".concat(this.value, " is not iterable"),
|
|
594
|
+
code: 1040,
|
|
595
|
+
status: "is-iterable"
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
return this;
|
|
599
|
+
}
|
|
600
|
+
}, {
|
|
601
|
+
key: "notToBeIterable",
|
|
602
|
+
value: function notToBeIterable() {
|
|
603
|
+
this._expected = true;
|
|
604
|
+
if ((0, _base.isIterable)(this.value)) {
|
|
605
|
+
throw new TestException({
|
|
606
|
+
message: "".concat(this.value, " is iterable"),
|
|
607
|
+
code: 1060,
|
|
608
|
+
status: "not-iterable"
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
return this;
|
|
612
|
+
}
|
|
613
|
+
}, {
|
|
614
|
+
key: "toBeSubClassOf",
|
|
615
|
+
value: function toBeSubClassOf(type) {
|
|
616
|
+
this._expected = true;
|
|
617
|
+
if (!(0, _base.isSubClassOf)(this.value, type)) {
|
|
618
|
+
throw new TestException({
|
|
619
|
+
message: "".concat(this.value, " is not subclass of ").concat(type),
|
|
620
|
+
code: 1041,
|
|
621
|
+
status: "is-subclass-of"
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
return this;
|
|
625
|
+
}
|
|
626
|
+
}, {
|
|
627
|
+
key: "notToBeSubClassOf",
|
|
628
|
+
value: function notToBeSubClassOf(type) {
|
|
629
|
+
this._expected = true;
|
|
630
|
+
if ((0, _base.isSubClassOf)(this.value, type)) {
|
|
631
|
+
throw new TestException({
|
|
632
|
+
message: "".concat(this.value, " is subclass of ").concat(type),
|
|
633
|
+
code: 1061,
|
|
634
|
+
status: "not-subclassof"
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
return this;
|
|
638
|
+
}
|
|
639
|
+
}, {
|
|
640
|
+
key: "toBeInstanceOf",
|
|
641
|
+
value: function toBeInstanceOf(type) {
|
|
642
|
+
this._expected = true;
|
|
643
|
+
if (!(this.value instanceof type)) {
|
|
644
|
+
throw new TestException({
|
|
645
|
+
message: "".concat(this.value, " is not instance of ").concat(type),
|
|
646
|
+
code: 1042,
|
|
647
|
+
status: "instanceof"
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
return this;
|
|
651
|
+
}
|
|
652
|
+
}, {
|
|
653
|
+
key: "notToBeInstanceOf",
|
|
654
|
+
value: function notToBeInstanceOf(type) {
|
|
655
|
+
this._expected = true;
|
|
656
|
+
if (this.value instanceof type) {
|
|
657
|
+
throw new TestException({
|
|
658
|
+
message: "".concat(this.value, " is instance of ").concat(type),
|
|
659
|
+
code: 1062,
|
|
660
|
+
status: "not-instanceof"
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
return this;
|
|
664
|
+
}
|
|
665
|
+
}, {
|
|
666
|
+
key: "toMatch",
|
|
667
|
+
value: function toMatch(pattern, flags) {
|
|
668
|
+
this._expected = true;
|
|
669
|
+
var r = new RegExp(pattern, flags);
|
|
670
|
+
if (!r.test(this.value)) {
|
|
671
|
+
throw new TestException({
|
|
672
|
+
message: "".concat(this.value, " does not match ").concat(pattern),
|
|
673
|
+
code: 1043,
|
|
674
|
+
status: "match"
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
return this;
|
|
678
|
+
}
|
|
679
|
+
}, {
|
|
680
|
+
key: "notToMatch",
|
|
681
|
+
value: function notToMatch(pattern, flags) {
|
|
682
|
+
this._expected = true;
|
|
683
|
+
var r = new RegExp(pattern, flags);
|
|
684
|
+
if (r.test(this.value)) {
|
|
685
|
+
throw new TestException({
|
|
686
|
+
message: "".concat(this.value, " matches ").concat(pattern),
|
|
687
|
+
code: 1070,
|
|
688
|
+
status: "match"
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
return this;
|
|
692
|
+
}
|
|
693
|
+
}, {
|
|
694
|
+
key: "doesNotMatch",
|
|
695
|
+
value: function doesNotMatch(pattern, flags) {
|
|
696
|
+
this._expected = true;
|
|
697
|
+
var r = new RegExp(pattern, flags);
|
|
698
|
+
if (r.test(this.value)) {
|
|
699
|
+
throw new TestException({
|
|
700
|
+
message: "".concat(this.value, " matches ").concat(pattern),
|
|
701
|
+
code: 1063,
|
|
702
|
+
status: "not-match"
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
return this;
|
|
706
|
+
}
|
|
707
|
+
}, {
|
|
708
|
+
key: "toBeDefined",
|
|
709
|
+
value: function toBeDefined() {
|
|
710
|
+
this._expected = true;
|
|
711
|
+
if (this.value === undefined) {
|
|
712
|
+
throw new TestException({
|
|
713
|
+
message: "value is undefined",
|
|
714
|
+
code: 1006,
|
|
715
|
+
status: "undefined"
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
return this;
|
|
719
|
+
}
|
|
720
|
+
}, {
|
|
721
|
+
key: "notToBeDefined",
|
|
722
|
+
value: function notToBeDefined() {
|
|
723
|
+
this._expected = true;
|
|
724
|
+
if (this.value !== undefined) {
|
|
725
|
+
throw new TestException({
|
|
726
|
+
message: "value is defined",
|
|
727
|
+
code: 1071,
|
|
728
|
+
status: "defined"
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
return this;
|
|
732
|
+
}
|
|
733
|
+
}, {
|
|
734
|
+
key: "toBeUndefined",
|
|
735
|
+
value: function toBeUndefined() {
|
|
736
|
+
this._expected = true;
|
|
737
|
+
if (this.value !== undefined) {
|
|
738
|
+
throw new TestException({
|
|
739
|
+
message: "value is defined",
|
|
740
|
+
code: 1007,
|
|
741
|
+
status: "defined"
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
return this;
|
|
745
|
+
}
|
|
746
|
+
}, {
|
|
747
|
+
key: "notToBeUndefined",
|
|
748
|
+
value: function notToBeUndefined() {
|
|
749
|
+
this._expected = true;
|
|
750
|
+
if (this.value === undefined) {
|
|
751
|
+
throw new TestException({
|
|
752
|
+
message: "value is undefined",
|
|
753
|
+
code: 1072,
|
|
754
|
+
status: "undefined"
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
return this;
|
|
758
|
+
}
|
|
759
|
+
}, {
|
|
760
|
+
key: "toBeNull",
|
|
761
|
+
value: function toBeNull() {
|
|
762
|
+
this._expected = true;
|
|
763
|
+
if (this.value !== null) {
|
|
764
|
+
throw new TestException({
|
|
765
|
+
message: "value is not null",
|
|
766
|
+
code: 1008,
|
|
767
|
+
status: "not-null"
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
return this;
|
|
771
|
+
}
|
|
772
|
+
}, {
|
|
773
|
+
key: "notToBeNull",
|
|
774
|
+
value: function notToBeNull() {
|
|
775
|
+
this._expected = true;
|
|
776
|
+
if (this.value === null) {
|
|
777
|
+
throw new TestException({
|
|
778
|
+
message: "value is null",
|
|
779
|
+
code: 1009,
|
|
780
|
+
status: "null"
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
return this;
|
|
784
|
+
}
|
|
785
|
+
}, {
|
|
786
|
+
key: "toBeNullOrUndefined",
|
|
787
|
+
value: function toBeNullOrUndefined() {
|
|
788
|
+
this._expected = true;
|
|
789
|
+
if (this.value == null) {} else {
|
|
790
|
+
throw new TestException({
|
|
791
|
+
message: "value is not null/undefined",
|
|
792
|
+
code: 1010,
|
|
793
|
+
status: "not-null-or-undefined"
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
return this;
|
|
797
|
+
}
|
|
798
|
+
}, {
|
|
799
|
+
key: "notToBeNullOrUndefined",
|
|
800
|
+
value: function notToBeNullOrUndefined() {
|
|
801
|
+
this._expected = true;
|
|
802
|
+
if (this.value == null) {
|
|
803
|
+
throw new TestException({
|
|
804
|
+
message: "value is null/undefined",
|
|
805
|
+
code: 1011,
|
|
806
|
+
status: "null-or-undefined"
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
return this;
|
|
810
|
+
}
|
|
811
|
+
}, {
|
|
812
|
+
key: "toBeEmptyArray",
|
|
813
|
+
value: function toBeEmptyArray() {
|
|
814
|
+
this._expected = true;
|
|
815
|
+
if ((0, _base.isSomeArray)(this.value)) {
|
|
816
|
+
throw new TestException({
|
|
817
|
+
message: "".concat(this.value, " is some array"),
|
|
818
|
+
code: 1059,
|
|
819
|
+
status: "to-be-empty-array"
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
return this;
|
|
823
|
+
}
|
|
824
|
+
}, {
|
|
825
|
+
key: "toBeValid",
|
|
826
|
+
value: function toBeValid(fnValidation) {
|
|
827
|
+
this._expected = true;
|
|
828
|
+
if (!(0, _base.isFunction)(fnValidation)) {
|
|
829
|
+
throw new TestException({
|
|
830
|
+
message: "fnValidation is not function",
|
|
831
|
+
code: 1064,
|
|
832
|
+
status: "to-be-valid"
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
if (!fnValidation(this.value)) {
|
|
836
|
+
throw new TestException({
|
|
837
|
+
message: "".concat(this.value, " is not valid"),
|
|
838
|
+
code: 1065,
|
|
839
|
+
status: "to-be-valid"
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
return this;
|
|
843
|
+
}
|
|
844
|
+
}, {
|
|
845
|
+
key: "notToBeValid",
|
|
846
|
+
value: function notToBeValid(fnValidation) {
|
|
847
|
+
this._expected = true;
|
|
848
|
+
if (!(0, _base.isFunction)(fnValidation)) {
|
|
849
|
+
throw new TestException({
|
|
850
|
+
message: "fnValidation is not function",
|
|
851
|
+
code: 1066,
|
|
852
|
+
status: "not-to-be-valid"
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
if (fnValidation(this.value)) {
|
|
856
|
+
throw new TestException({
|
|
857
|
+
message: "".concat(this.value, " is valid"),
|
|
858
|
+
code: 1067,
|
|
859
|
+
status: "not-to-be-valid"
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
return this;
|
|
863
|
+
}
|
|
864
|
+
}, {
|
|
865
|
+
key: "toThrow",
|
|
866
|
+
value: function toThrow(ex) {
|
|
867
|
+
var shape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
868
|
+
var strict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
869
|
+
this._expected = true;
|
|
870
|
+
if (!(0, _base.isFunction)(this.value)) {
|
|
871
|
+
throw new TestException({
|
|
872
|
+
message: "given argument is not a function.",
|
|
873
|
+
code: 1012,
|
|
874
|
+
status: "not-func"
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
var ok = false;
|
|
878
|
+
try {
|
|
879
|
+
this.value();
|
|
880
|
+
ok = true;
|
|
881
|
+
} catch (e) {
|
|
882
|
+
if (ex !== undefined) {
|
|
883
|
+
if ((0, _base.isPrimitive)(ex)) {
|
|
884
|
+
if (e !== ex) {
|
|
670
885
|
throw new TestException({
|
|
671
|
-
message:
|
|
672
|
-
code:
|
|
673
|
-
status: "incorrect-throw-
|
|
886
|
+
message: "given function threw incorrect error.",
|
|
887
|
+
code: 1018,
|
|
888
|
+
status: "incorrect-throw-error"
|
|
674
889
|
});
|
|
675
890
|
}
|
|
891
|
+
} else if ((0, _base.isFunction)(ex)) {
|
|
892
|
+
if (!(e instanceof ex)) {
|
|
893
|
+
throw new TestException({
|
|
894
|
+
message: "given function threw incorrect instance.",
|
|
895
|
+
code: 1019,
|
|
896
|
+
status: "incorrect-throw-instance"
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
} else if ((0, _base.isObject)(ex)) {
|
|
900
|
+
if (shape) {
|
|
901
|
+
if (!(0, _base.equals)(e, ex, strict)) {
|
|
902
|
+
throw new TestException({
|
|
903
|
+
message: "given function threw incorrect object shape.",
|
|
904
|
+
code: 1020,
|
|
905
|
+
status: "incorrect-throw-shape"
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
} else {
|
|
909
|
+
if (e !== ex) {
|
|
910
|
+
throw new TestException({
|
|
911
|
+
message: "given function threw incorrect object.",
|
|
912
|
+
code: 1021,
|
|
913
|
+
status: "incorrect-throw-object"
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
}
|
|
676
917
|
} else {
|
|
677
918
|
if (e !== ex) {
|
|
678
919
|
throw new TestException({
|
|
679
|
-
message:
|
|
680
|
-
code:
|
|
681
|
-
status: "incorrect-throw-
|
|
920
|
+
message: "given function threw incorrect value.",
|
|
921
|
+
code: 1022,
|
|
922
|
+
status: "incorrect-throw-value"
|
|
682
923
|
});
|
|
683
924
|
}
|
|
684
925
|
}
|
|
685
|
-
} else {
|
|
686
|
-
if (e !== ex) {
|
|
687
|
-
throw new TestException({
|
|
688
|
-
message: `given function threw incorrect value.`,
|
|
689
|
-
code: 1022,
|
|
690
|
-
status: "incorrect-throw-value"
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
926
|
}
|
|
694
927
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
ok = true;
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
} else if (isFunction(ex)) {
|
|
729
|
-
if (!(e instanceof ex)) {
|
|
730
|
-
throw new TestException({
|
|
731
|
-
message: `given function threw incorrect instance.`,
|
|
732
|
-
code: 1019,
|
|
733
|
-
status: "incorrect-throw-instance"
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
} else if (isObject(ex)) {
|
|
737
|
-
if (shape) {
|
|
738
|
-
if (!equals(e, ex, strict)) {
|
|
928
|
+
if (ok) {
|
|
929
|
+
throw new TestException({
|
|
930
|
+
message: "given function ran without throwing any errors.",
|
|
931
|
+
code: 1013,
|
|
932
|
+
status: "ran-to-completion"
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
return this;
|
|
936
|
+
}
|
|
937
|
+
}, {
|
|
938
|
+
key: "notToThrow",
|
|
939
|
+
value: function notToThrow(ex) {
|
|
940
|
+
var shape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
941
|
+
var strict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
942
|
+
this._expected = true;
|
|
943
|
+
if (!(0, _base.isFunction)(this.value)) {
|
|
944
|
+
throw new TestException({
|
|
945
|
+
message: "given argument is not a function.",
|
|
946
|
+
code: 1012,
|
|
947
|
+
status: "not-func"
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
var ok = true;
|
|
951
|
+
var error;
|
|
952
|
+
try {
|
|
953
|
+
this.value();
|
|
954
|
+
ok = false;
|
|
955
|
+
} catch (e) {
|
|
956
|
+
error = e;
|
|
957
|
+
if (ex !== undefined) {
|
|
958
|
+
if ((0, _base.isPrimitive)(ex)) {
|
|
959
|
+
if (e === ex) {
|
|
739
960
|
throw new TestException({
|
|
740
|
-
message:
|
|
741
|
-
code:
|
|
742
|
-
status: "incorrect-throw-
|
|
961
|
+
message: "given function threw incorrect error.",
|
|
962
|
+
code: 1018,
|
|
963
|
+
status: "incorrect-throw-error"
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
} else if ((0, _base.isFunction)(ex)) {
|
|
967
|
+
if (e instanceof ex) {
|
|
968
|
+
throw new TestException({
|
|
969
|
+
message: "given function threw incorrect instance.",
|
|
970
|
+
code: 1019,
|
|
971
|
+
status: "incorrect-throw-instance"
|
|
743
972
|
});
|
|
744
973
|
}
|
|
974
|
+
} else if ((0, _base.isObject)(ex)) {
|
|
975
|
+
if (shape) {
|
|
976
|
+
if ((0, _base.equals)(e, ex, strict)) {
|
|
977
|
+
throw new TestException({
|
|
978
|
+
message: "given function threw incorrect object shape.",
|
|
979
|
+
code: 1020,
|
|
980
|
+
status: "incorrect-throw-shape"
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
} else {
|
|
984
|
+
if (e === ex) {
|
|
985
|
+
throw new TestException({
|
|
986
|
+
message: "given function threw incorrect object.",
|
|
987
|
+
code: 1021,
|
|
988
|
+
status: "incorrect-throw-object"
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
}
|
|
745
992
|
} else {
|
|
746
|
-
if (e
|
|
993
|
+
if (e === ex) {
|
|
747
994
|
throw new TestException({
|
|
748
|
-
message:
|
|
749
|
-
code:
|
|
750
|
-
status: "incorrect-throw-
|
|
995
|
+
message: "given function threw incorrect value.",
|
|
996
|
+
code: 1022,
|
|
997
|
+
status: "incorrect-throw-value"
|
|
751
998
|
});
|
|
752
999
|
}
|
|
753
1000
|
}
|
|
754
|
-
} else {
|
|
755
|
-
if (e !== ex) {
|
|
756
|
-
throw new TestException({
|
|
757
|
-
message: `given function threw incorrect value.`,
|
|
758
|
-
code: 1022,
|
|
759
|
-
status: "incorrect-throw-value"
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
1001
|
}
|
|
763
1002
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1003
|
+
if (ok) {
|
|
1004
|
+
throw new TestException({
|
|
1005
|
+
message: "given function threw an error.",
|
|
1006
|
+
code: 1014,
|
|
1007
|
+
status: "ran-to-error",
|
|
1008
|
+
innerException: error
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
return this;
|
|
1012
|
+
}
|
|
1013
|
+
}, {
|
|
1014
|
+
key: "toThrowAsync",
|
|
1015
|
+
value: function () {
|
|
1016
|
+
var _toThrowAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ex) {
|
|
1017
|
+
var shape,
|
|
1018
|
+
strict,
|
|
1019
|
+
ok,
|
|
1020
|
+
_args = arguments;
|
|
1021
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1022
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1023
|
+
case 0:
|
|
1024
|
+
shape = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
1025
|
+
strict = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
|
1026
|
+
this._expected = true;
|
|
1027
|
+
if ((0, _base.isFunction)(this.value)) {
|
|
1028
|
+
_context.next = 5;
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
1031
|
+
throw new TestException({
|
|
1032
|
+
message: "given argument is not a function.",
|
|
1033
|
+
code: 1012,
|
|
1034
|
+
status: "not-func"
|
|
1035
|
+
});
|
|
1036
|
+
case 5:
|
|
1037
|
+
ok = false;
|
|
1038
|
+
_context.prev = 6;
|
|
1039
|
+
_context.next = 9;
|
|
1040
|
+
return this.value();
|
|
1041
|
+
case 9:
|
|
1042
|
+
ok = true;
|
|
1043
|
+
_context.next = 37;
|
|
1044
|
+
break;
|
|
1045
|
+
case 12:
|
|
1046
|
+
_context.prev = 12;
|
|
1047
|
+
_context.t0 = _context["catch"](6);
|
|
1048
|
+
if (!(ex !== undefined)) {
|
|
1049
|
+
_context.next = 37;
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
if (!(0, _base.isPrimitive)(ex)) {
|
|
1053
|
+
_context.next = 20;
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
if (!(_context.t0 !== ex)) {
|
|
1057
|
+
_context.next = 18;
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
throw new TestException({
|
|
1061
|
+
message: "given function threw incorrect error.",
|
|
1062
|
+
code: 1018,
|
|
1063
|
+
status: "incorrect-throw-error"
|
|
1064
|
+
});
|
|
1065
|
+
case 18:
|
|
1066
|
+
_context.next = 37;
|
|
1067
|
+
break;
|
|
1068
|
+
case 20:
|
|
1069
|
+
if (!(0, _base.isFunction)(ex)) {
|
|
1070
|
+
_context.next = 25;
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
if (_context.t0 instanceof ex) {
|
|
1074
|
+
_context.next = 23;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
throw new TestException({
|
|
1078
|
+
message: "given function threw incorrect instance.",
|
|
1079
|
+
code: 1019,
|
|
1080
|
+
status: "incorrect-throw-instance"
|
|
1081
|
+
});
|
|
1082
|
+
case 23:
|
|
1083
|
+
_context.next = 37;
|
|
1084
|
+
break;
|
|
1085
|
+
case 25:
|
|
1086
|
+
if (!(0, _base.isObject)(ex)) {
|
|
1087
|
+
_context.next = 35;
|
|
1088
|
+
break;
|
|
1089
|
+
}
|
|
1090
|
+
if (!shape) {
|
|
1091
|
+
_context.next = 31;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
if ((0, _base.equals)(_context.t0, ex, strict)) {
|
|
1095
|
+
_context.next = 29;
|
|
1096
|
+
break;
|
|
1097
|
+
}
|
|
810
1098
|
throw new TestException({
|
|
811
|
-
message:
|
|
1099
|
+
message: "given function threw incorrect object shape.",
|
|
812
1100
|
code: 1020,
|
|
813
1101
|
status: "incorrect-throw-shape"
|
|
814
1102
|
});
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1103
|
+
case 29:
|
|
1104
|
+
_context.next = 33;
|
|
1105
|
+
break;
|
|
1106
|
+
case 31:
|
|
1107
|
+
if (!(_context.t0 !== ex)) {
|
|
1108
|
+
_context.next = 33;
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
818
1111
|
throw new TestException({
|
|
819
|
-
message:
|
|
1112
|
+
message: "given function threw incorrect object.",
|
|
820
1113
|
code: 1021,
|
|
821
1114
|
status: "incorrect-throw-object"
|
|
822
1115
|
});
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
1116
|
+
case 33:
|
|
1117
|
+
_context.next = 37;
|
|
1118
|
+
break;
|
|
1119
|
+
case 35:
|
|
1120
|
+
if (!(_context.t0 !== ex)) {
|
|
1121
|
+
_context.next = 37;
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
throw new TestException({
|
|
1125
|
+
message: "given function threw incorrect value.",
|
|
1126
|
+
code: 1022,
|
|
1127
|
+
status: "incorrect-throw-value"
|
|
1128
|
+
});
|
|
1129
|
+
case 37:
|
|
1130
|
+
if (!ok) {
|
|
1131
|
+
_context.next = 39;
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1134
|
+
throw new TestException({
|
|
1135
|
+
message: "given function ran without throwing any errors.",
|
|
1136
|
+
code: 1013,
|
|
1137
|
+
status: "ran-to-completion"
|
|
1138
|
+
});
|
|
1139
|
+
case 39:
|
|
1140
|
+
return _context.abrupt("return", this);
|
|
1141
|
+
case 40:
|
|
1142
|
+
case "end":
|
|
1143
|
+
return _context.stop();
|
|
832
1144
|
}
|
|
833
|
-
}
|
|
1145
|
+
}, _callee, this, [[6, 12]]);
|
|
1146
|
+
}));
|
|
1147
|
+
function toThrowAsync(_x) {
|
|
1148
|
+
return _toThrowAsync.apply(this, arguments);
|
|
834
1149
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1150
|
+
return toThrowAsync;
|
|
1151
|
+
}()
|
|
1152
|
+
}, {
|
|
1153
|
+
key: "notToThrowAsync",
|
|
1154
|
+
value: function () {
|
|
1155
|
+
var _notToThrowAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ex) {
|
|
1156
|
+
var shape,
|
|
1157
|
+
strict,
|
|
1158
|
+
ok,
|
|
1159
|
+
error,
|
|
1160
|
+
_args2 = arguments;
|
|
1161
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1162
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1163
|
+
case 0:
|
|
1164
|
+
shape = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : false;
|
|
1165
|
+
strict = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
|
|
1166
|
+
this._expected = true;
|
|
1167
|
+
if ((0, _base.isFunction)(this.value)) {
|
|
1168
|
+
_context2.next = 5;
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
throw new TestException({
|
|
1172
|
+
message: "given argument is not a function.",
|
|
1173
|
+
code: 1012,
|
|
1174
|
+
status: "not-func"
|
|
1175
|
+
});
|
|
1176
|
+
case 5:
|
|
1177
|
+
ok = true;
|
|
1178
|
+
_context2.prev = 6;
|
|
1179
|
+
_context2.next = 9;
|
|
1180
|
+
return this.value();
|
|
1181
|
+
case 9:
|
|
1182
|
+
ok = false;
|
|
1183
|
+
_context2.next = 38;
|
|
1184
|
+
break;
|
|
1185
|
+
case 12:
|
|
1186
|
+
_context2.prev = 12;
|
|
1187
|
+
_context2.t0 = _context2["catch"](6);
|
|
1188
|
+
error = _context2.t0;
|
|
1189
|
+
if (!(ex !== undefined)) {
|
|
1190
|
+
_context2.next = 38;
|
|
1191
|
+
break;
|
|
1192
|
+
}
|
|
1193
|
+
if (!(0, _base.isPrimitive)(ex)) {
|
|
1194
|
+
_context2.next = 21;
|
|
1195
|
+
break;
|
|
1196
|
+
}
|
|
1197
|
+
if (!(_context2.t0 === ex)) {
|
|
1198
|
+
_context2.next = 19;
|
|
1199
|
+
break;
|
|
1200
|
+
}
|
|
1201
|
+
throw new TestException({
|
|
1202
|
+
message: "given function threw incorrect error.",
|
|
1203
|
+
code: 1018,
|
|
1204
|
+
status: "incorrect-throw-error"
|
|
1205
|
+
});
|
|
1206
|
+
case 19:
|
|
1207
|
+
_context2.next = 38;
|
|
1208
|
+
break;
|
|
1209
|
+
case 21:
|
|
1210
|
+
if (!(0, _base.isFunction)(ex)) {
|
|
1211
|
+
_context2.next = 26;
|
|
1212
|
+
break;
|
|
1213
|
+
}
|
|
1214
|
+
if (!(_context2.t0 instanceof ex)) {
|
|
1215
|
+
_context2.next = 24;
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
throw new TestException({
|
|
1219
|
+
message: "given function threw incorrect instance.",
|
|
1220
|
+
code: 1019,
|
|
1221
|
+
status: "incorrect-throw-instance"
|
|
1222
|
+
});
|
|
1223
|
+
case 24:
|
|
1224
|
+
_context2.next = 38;
|
|
1225
|
+
break;
|
|
1226
|
+
case 26:
|
|
1227
|
+
if (!(0, _base.isObject)(ex)) {
|
|
1228
|
+
_context2.next = 36;
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
if (!shape) {
|
|
1232
|
+
_context2.next = 32;
|
|
1233
|
+
break;
|
|
1234
|
+
}
|
|
1235
|
+
if (!(0, _base.equals)(_context2.t0, ex, strict)) {
|
|
1236
|
+
_context2.next = 30;
|
|
1237
|
+
break;
|
|
1238
|
+
}
|
|
882
1239
|
throw new TestException({
|
|
883
|
-
message:
|
|
1240
|
+
message: "given function threw incorrect object shape.",
|
|
884
1241
|
code: 1020,
|
|
885
1242
|
status: "incorrect-throw-shape"
|
|
886
1243
|
});
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1244
|
+
case 30:
|
|
1245
|
+
_context2.next = 34;
|
|
1246
|
+
break;
|
|
1247
|
+
case 32:
|
|
1248
|
+
if (!(_context2.t0 === ex)) {
|
|
1249
|
+
_context2.next = 34;
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
890
1252
|
throw new TestException({
|
|
891
|
-
message:
|
|
1253
|
+
message: "given function threw incorrect object.",
|
|
892
1254
|
code: 1021,
|
|
893
1255
|
status: "incorrect-throw-object"
|
|
894
1256
|
});
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1257
|
+
case 34:
|
|
1258
|
+
_context2.next = 38;
|
|
1259
|
+
break;
|
|
1260
|
+
case 36:
|
|
1261
|
+
if (!(_context2.t0 === ex)) {
|
|
1262
|
+
_context2.next = 38;
|
|
1263
|
+
break;
|
|
1264
|
+
}
|
|
1265
|
+
throw new TestException({
|
|
1266
|
+
message: "given function threw incorrect value.",
|
|
1267
|
+
code: 1022,
|
|
1268
|
+
status: "incorrect-throw-value"
|
|
1269
|
+
});
|
|
1270
|
+
case 38:
|
|
1271
|
+
if (!ok) {
|
|
1272
|
+
_context2.next = 40;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
throw new TestException({
|
|
1276
|
+
message: "given function threw an error.",
|
|
1277
|
+
code: 1014,
|
|
1278
|
+
status: "ran-to-error",
|
|
1279
|
+
innerException: error
|
|
1280
|
+
});
|
|
1281
|
+
case 40:
|
|
1282
|
+
return _context2.abrupt("return", this);
|
|
1283
|
+
case 41:
|
|
1284
|
+
case "end":
|
|
1285
|
+
return _context2.stop();
|
|
904
1286
|
}
|
|
905
|
-
}
|
|
1287
|
+
}, _callee2, this, [[6, 12]]);
|
|
1288
|
+
}));
|
|
1289
|
+
function notToThrowAsync(_x2) {
|
|
1290
|
+
return _notToThrowAsync.apply(this, arguments);
|
|
906
1291
|
}
|
|
1292
|
+
return notToThrowAsync;
|
|
1293
|
+
}()
|
|
1294
|
+
}, {
|
|
1295
|
+
key: "toBeTruthy",
|
|
1296
|
+
value: function toBeTruthy() {
|
|
1297
|
+
this._expected = true;
|
|
1298
|
+
if (this.value) {} else {
|
|
1299
|
+
throw new TestException({
|
|
1300
|
+
message: "".concat(this.value, " is not truthy"),
|
|
1301
|
+
code: 1015,
|
|
1302
|
+
status: "not-truthy"
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
return this;
|
|
1306
|
+
}
|
|
1307
|
+
}, {
|
|
1308
|
+
key: "toBeTrue",
|
|
1309
|
+
value: function toBeTrue() {
|
|
1310
|
+
return this.toBeTruthy();
|
|
1311
|
+
}
|
|
1312
|
+
}, {
|
|
1313
|
+
key: "toBeFalsy",
|
|
1314
|
+
value: function toBeFalsy() {
|
|
1315
|
+
this._expected = true;
|
|
1316
|
+
if (!this.value) {} else {
|
|
1317
|
+
throw new TestException({
|
|
1318
|
+
message: "".concat(this.value, " is not falsy"),
|
|
1319
|
+
code: 1016,
|
|
1320
|
+
status: "not-falsy"
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
return this;
|
|
1324
|
+
}
|
|
1325
|
+
}, {
|
|
1326
|
+
key: "toBeFalse",
|
|
1327
|
+
value: function toBeFalse() {
|
|
1328
|
+
return this.toBeFalsy();
|
|
1329
|
+
}
|
|
1330
|
+
}, {
|
|
1331
|
+
key: "toBeNaN",
|
|
1332
|
+
value: function toBeNaN() {
|
|
1333
|
+
this._expected = true;
|
|
1334
|
+
if (isNaN(this.value)) {} else {
|
|
1335
|
+
throw new TestException({
|
|
1336
|
+
message: "".concat(this.value, " is not NaN"),
|
|
1337
|
+
code: 1017,
|
|
1338
|
+
status: "not-nan"
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
return this;
|
|
1342
|
+
}
|
|
1343
|
+
}, {
|
|
1344
|
+
key: "notToBeNaN",
|
|
1345
|
+
value: function notToBeNaN() {
|
|
1346
|
+
this._expected = true;
|
|
1347
|
+
if (!isNaN(this.value)) {} else {
|
|
1348
|
+
throw new TestException({
|
|
1349
|
+
message: "".concat(this.value, " is NaN"),
|
|
1350
|
+
code: 1023,
|
|
1351
|
+
status: "is-nan"
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
return this;
|
|
907
1355
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
innerException: error
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
return this;
|
|
917
|
-
}
|
|
918
|
-
toBeTruthy() {
|
|
919
|
-
this._expected = true;
|
|
920
|
-
if (this.value) {} else {
|
|
921
|
-
throw new TestException({
|
|
922
|
-
message: `${this.value} is not truthy`,
|
|
923
|
-
code: 1015,
|
|
924
|
-
status: "not-truthy"
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
return this;
|
|
928
|
-
}
|
|
929
|
-
toBeTrue() {
|
|
930
|
-
return this.toBeTruthy();
|
|
931
|
-
}
|
|
932
|
-
toBeFalsy() {
|
|
933
|
-
this._expected = true;
|
|
934
|
-
if (!this.value) {} else {
|
|
935
|
-
throw new TestException({
|
|
936
|
-
message: `${this.value} is not falsy`,
|
|
937
|
-
code: 1016,
|
|
938
|
-
status: "not-falsy"
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
return this;
|
|
942
|
-
}
|
|
943
|
-
toBeFalse() {
|
|
944
|
-
return this.toBeFalsy();
|
|
945
|
-
}
|
|
946
|
-
toBeNaN() {
|
|
947
|
-
this._expected = true;
|
|
948
|
-
if (isNaN(this.value)) {} else {
|
|
949
|
-
throw new TestException({
|
|
950
|
-
message: `${this.value} is not NaN`,
|
|
951
|
-
code: 1017,
|
|
952
|
-
status: "not-nan"
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
return this;
|
|
956
|
-
}
|
|
957
|
-
notToBeNaN() {
|
|
958
|
-
this._expected = true;
|
|
959
|
-
if (!isNaN(this.value)) {} else {
|
|
960
|
-
throw new TestException({
|
|
961
|
-
message: `${this.value} is NaN`,
|
|
962
|
-
code: 1023,
|
|
963
|
-
status: "is-nan"
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
return this;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
class Test {
|
|
970
|
-
constructor(name, fn) {
|
|
1356
|
+
}]);
|
|
1357
|
+
}();
|
|
1358
|
+
var Test = exports.Test = /*#__PURE__*/function () {
|
|
1359
|
+
function Test(name, fn) {
|
|
1360
|
+
_classCallCheck(this, Test);
|
|
971
1361
|
this.name = name;
|
|
972
1362
|
this.fn = fn;
|
|
973
1363
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1364
|
+
return _createClass(Test, [{
|
|
1365
|
+
key: "run",
|
|
1366
|
+
value: function run() {
|
|
1367
|
+
var _this2 = this;
|
|
1368
|
+
return new Promise(function (res) {
|
|
1369
|
+
var start = new Date();
|
|
1370
|
+
if ((0, _base.isFunction)(_this2.fn)) {
|
|
1371
|
+
var _expect = new Expect();
|
|
1372
|
+
try {
|
|
1373
|
+
var _result = _this2.fn(function (x) {
|
|
1374
|
+
_expect.value = x;
|
|
1375
|
+
return _expect;
|
|
1376
|
+
});
|
|
1377
|
+
if (_result && (0, _base.isFunction)(_result.then)) {
|
|
1378
|
+
_result.then(function (result) {
|
|
1379
|
+
res({
|
|
1380
|
+
success: true,
|
|
1381
|
+
test: _this2.name,
|
|
1382
|
+
result: result,
|
|
1383
|
+
time: new Date() - start,
|
|
1384
|
+
expected: _expect.expected
|
|
1385
|
+
});
|
|
1386
|
+
})["catch"](function (ex) {
|
|
1387
|
+
res({
|
|
1388
|
+
success: false,
|
|
1389
|
+
test: _this2.name,
|
|
1390
|
+
time: new Date() - start,
|
|
1391
|
+
expected: _expect.expected,
|
|
1392
|
+
err: new TestException({
|
|
1393
|
+
message: "test '".concat(_this2.name, "' failed."),
|
|
1394
|
+
code: 501,
|
|
1395
|
+
status: "failed",
|
|
1396
|
+
innerException: ex
|
|
1397
|
+
})
|
|
1398
|
+
});
|
|
1399
|
+
});
|
|
1400
|
+
} else {
|
|
986
1401
|
res({
|
|
987
1402
|
success: true,
|
|
988
|
-
test:
|
|
989
|
-
result,
|
|
1403
|
+
test: _this2.name,
|
|
990
1404
|
time: new Date() - start,
|
|
1405
|
+
result: _result,
|
|
991
1406
|
expected: _expect.expected
|
|
992
1407
|
});
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
success: false,
|
|
996
|
-
test: this.name,
|
|
997
|
-
time: new Date() - start,
|
|
998
|
-
expected: _expect.expected,
|
|
999
|
-
err: new TestException({
|
|
1000
|
-
message: `test '${this.name}' failed.`,
|
|
1001
|
-
code: 501,
|
|
1002
|
-
status: "failed",
|
|
1003
|
-
innerException: ex
|
|
1004
|
-
})
|
|
1005
|
-
});
|
|
1006
|
-
});
|
|
1007
|
-
} else {
|
|
1408
|
+
}
|
|
1409
|
+
} catch (ex) {
|
|
1008
1410
|
res({
|
|
1009
|
-
success:
|
|
1010
|
-
test:
|
|
1411
|
+
success: false,
|
|
1412
|
+
test: _this2.name,
|
|
1011
1413
|
time: new Date() - start,
|
|
1012
|
-
|
|
1013
|
-
|
|
1414
|
+
expected: _expect.expected,
|
|
1415
|
+
err: new TestException({
|
|
1416
|
+
message: "test '".concat(_this2.name, "' failed."),
|
|
1417
|
+
code: 501,
|
|
1418
|
+
status: "failed",
|
|
1419
|
+
innerException: ex
|
|
1420
|
+
})
|
|
1014
1421
|
});
|
|
1015
1422
|
}
|
|
1016
|
-
}
|
|
1423
|
+
} else {
|
|
1017
1424
|
res({
|
|
1018
1425
|
success: false,
|
|
1019
|
-
test:
|
|
1426
|
+
test: _this2.name,
|
|
1020
1427
|
time: new Date() - start,
|
|
1021
|
-
expected: _expect.expected,
|
|
1022
1428
|
err: new TestException({
|
|
1023
|
-
message:
|
|
1024
|
-
code:
|
|
1025
|
-
status: "
|
|
1026
|
-
innerException: ex
|
|
1429
|
+
message: "test '".concat(_this2.name, "' does not have a function to be called."),
|
|
1430
|
+
code: 500,
|
|
1431
|
+
status: "no-func"
|
|
1027
1432
|
})
|
|
1028
1433
|
});
|
|
1029
1434
|
}
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
const bgRed = "\x1b[41m";
|
|
1063
|
-
const bgGreen = "\x1b[42m";
|
|
1064
|
-
const bgYellow = "\x1b[43m";
|
|
1065
|
-
const bgBlue = "\x1b[44m";
|
|
1066
|
-
const bgMagenta = "\x1b[45m";
|
|
1067
|
-
const bgCyan = "\x1b[46m";
|
|
1068
|
-
const bgWhite = "\x1b[47m";
|
|
1069
|
-
const bgGray = "\x1b[100m";
|
|
1070
|
-
class TestRunner {
|
|
1071
|
-
constructor() {
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
}]);
|
|
1438
|
+
}();
|
|
1439
|
+
var reset = "\x1b[0m";
|
|
1440
|
+
var bright = "\x1b[1m";
|
|
1441
|
+
var dim = "\x1b[2m";
|
|
1442
|
+
var underscore = "\x1b[4m";
|
|
1443
|
+
var blink = "\x1b[5m";
|
|
1444
|
+
var reverse = "\x1b[7m";
|
|
1445
|
+
var hidden = "\x1b[8m";
|
|
1446
|
+
var fgBlack = "\x1b[30m";
|
|
1447
|
+
var fgRed = "\x1b[31m";
|
|
1448
|
+
var fgGreen = "\x1b[32m";
|
|
1449
|
+
var fgYellow = "\x1b[33m";
|
|
1450
|
+
var fgBlue = "\x1b[34m";
|
|
1451
|
+
var fgMagenta = "\x1b[35m";
|
|
1452
|
+
var fgCyan = "\x1b[36m";
|
|
1453
|
+
var fgWhite = "\x1b[37m";
|
|
1454
|
+
var fgGray = "\x1b[90m";
|
|
1455
|
+
var bgBlack = "\x1b[40m";
|
|
1456
|
+
var bgRed = "\x1b[41m";
|
|
1457
|
+
var bgGreen = "\x1b[42m";
|
|
1458
|
+
var bgYellow = "\x1b[43m";
|
|
1459
|
+
var bgBlue = "\x1b[44m";
|
|
1460
|
+
var bgMagenta = "\x1b[45m";
|
|
1461
|
+
var bgCyan = "\x1b[46m";
|
|
1462
|
+
var bgWhite = "\x1b[47m";
|
|
1463
|
+
var bgGray = "\x1b[100m";
|
|
1464
|
+
var TestRunner = /*#__PURE__*/function () {
|
|
1465
|
+
function TestRunner() {
|
|
1466
|
+
_classCallCheck(this, TestRunner);
|
|
1072
1467
|
this._passed = 0;
|
|
1073
1468
|
this._failed = 0;
|
|
1074
1469
|
this._unknown = 0;
|
|
1075
1470
|
this._results = [];
|
|
1076
1471
|
this._errors = [];
|
|
1077
1472
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
get result() {
|
|
1106
|
-
return {
|
|
1107
|
-
passed: this._passed,
|
|
1108
|
-
failed: this._failed,
|
|
1109
|
-
results: this._results,
|
|
1110
|
-
errors: this._errors
|
|
1111
|
-
};
|
|
1112
|
-
}
|
|
1113
|
-
run(tests, onProgress) {
|
|
1114
|
-
this._passed = 0;
|
|
1115
|
-
this._failed = 0;
|
|
1116
|
-
this._results = [];
|
|
1117
|
-
this._errors = [];
|
|
1118
|
-
return new Promise(res => {
|
|
1119
|
-
if (tests) {
|
|
1120
|
-
if (tests instanceof Test) {
|
|
1121
|
-
tests = [tests];
|
|
1122
|
-
}
|
|
1123
|
-
if (isArray(tests)) {
|
|
1124
|
-
const _tests = tests.map(test => {
|
|
1125
|
-
let _test = test;
|
|
1126
|
-
if (isArray(test)) {
|
|
1127
|
-
if (test.length == 2) {
|
|
1128
|
-
_test = new Test(test[0], test[1]);
|
|
1473
|
+
return _createClass(TestRunner, [{
|
|
1474
|
+
key: "_runSingle",
|
|
1475
|
+
value: function () {
|
|
1476
|
+
var _runSingle2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(test, onProgress, i) {
|
|
1477
|
+
var tr;
|
|
1478
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1479
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1480
|
+
case 0:
|
|
1481
|
+
if ((0, _base.isFunction)(onProgress)) {
|
|
1482
|
+
try {
|
|
1483
|
+
onProgress({
|
|
1484
|
+
source: this,
|
|
1485
|
+
test: test,
|
|
1486
|
+
index: i
|
|
1487
|
+
});
|
|
1488
|
+
} catch (ex) {
|
|
1489
|
+
this._errors.push({
|
|
1490
|
+
index: i,
|
|
1491
|
+
test: test.name,
|
|
1492
|
+
err: new TestException({
|
|
1493
|
+
message: "onProgress failed for test '".concat(test.name, " at index ").concat(i, "'."),
|
|
1494
|
+
code: 1500,
|
|
1495
|
+
status: "progress-failed",
|
|
1496
|
+
innerException: ex
|
|
1497
|
+
})
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1129
1500
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1501
|
+
_context3.next = 3;
|
|
1502
|
+
return test.run();
|
|
1503
|
+
case 3:
|
|
1504
|
+
tr = _context3.sent;
|
|
1505
|
+
this._results.push(tr);
|
|
1506
|
+
if (!tr.expected) {
|
|
1507
|
+
this._unknown++;
|
|
1508
|
+
} else if (tr.success) {
|
|
1509
|
+
this._passed++;
|
|
1510
|
+
} else {
|
|
1511
|
+
this._failed++;
|
|
1512
|
+
}
|
|
1513
|
+
case 6:
|
|
1514
|
+
case "end":
|
|
1515
|
+
return _context3.stop();
|
|
1516
|
+
}
|
|
1517
|
+
}, _callee3, this);
|
|
1518
|
+
}));
|
|
1519
|
+
function _runSingle(_x3, _x4, _x5) {
|
|
1520
|
+
return _runSingle2.apply(this, arguments);
|
|
1521
|
+
}
|
|
1522
|
+
return _runSingle;
|
|
1523
|
+
}()
|
|
1524
|
+
}, {
|
|
1525
|
+
key: "result",
|
|
1526
|
+
get: function get() {
|
|
1527
|
+
return {
|
|
1528
|
+
passed: this._passed,
|
|
1529
|
+
failed: this._failed,
|
|
1530
|
+
results: this._results,
|
|
1531
|
+
errors: this._errors
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
}, {
|
|
1535
|
+
key: "run",
|
|
1536
|
+
value: function run(tests, onProgress) {
|
|
1537
|
+
var _this3 = this;
|
|
1538
|
+
this._passed = 0;
|
|
1539
|
+
this._failed = 0;
|
|
1540
|
+
this._results = [];
|
|
1541
|
+
this._errors = [];
|
|
1542
|
+
return new Promise(function (res) {
|
|
1543
|
+
if (tests) {
|
|
1544
|
+
if (tests instanceof Test) {
|
|
1545
|
+
tests = [tests];
|
|
1546
|
+
}
|
|
1547
|
+
if ((0, _base.isArray)(tests)) {
|
|
1548
|
+
var _tests = tests.map(function (test) {
|
|
1549
|
+
var _test = test;
|
|
1550
|
+
if ((0, _base.isArray)(test)) {
|
|
1551
|
+
if (test.length == 2) {
|
|
1552
|
+
_test = new Test(test[0], test[1]);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return _test;
|
|
1556
|
+
}).filter(function (test) {
|
|
1557
|
+
return test instanceof Test;
|
|
1558
|
+
}).map(function (test, i) {
|
|
1559
|
+
return _this3._runSingle(test, onProgress, i);
|
|
1560
|
+
});
|
|
1561
|
+
Promise.all(_tests).then(function (_) {
|
|
1562
|
+
return res(_this3.result);
|
|
1563
|
+
})["catch"](function (ex) {
|
|
1564
|
+
_this3._errors.push({
|
|
1565
|
+
err: new TestException({
|
|
1566
|
+
message: "not all tests succeeded. check errors.",
|
|
1567
|
+
code: 1503,
|
|
1568
|
+
status: "partial-finished",
|
|
1569
|
+
innerException: ex
|
|
1570
|
+
})
|
|
1571
|
+
});
|
|
1572
|
+
res(_this3.result);
|
|
1573
|
+
});
|
|
1574
|
+
} else {
|
|
1575
|
+
_this3._errors.push({
|
|
1135
1576
|
err: new TestException({
|
|
1136
|
-
message:
|
|
1137
|
-
code:
|
|
1138
|
-
status: "
|
|
1139
|
-
innerException: ex
|
|
1577
|
+
message: "invalid tests. expected array or a single test.",
|
|
1578
|
+
code: 1502,
|
|
1579
|
+
status: "invalid-tests"
|
|
1140
1580
|
})
|
|
1141
1581
|
});
|
|
1142
|
-
res(
|
|
1143
|
-
}
|
|
1582
|
+
res(_this3.result);
|
|
1583
|
+
}
|
|
1144
1584
|
} else {
|
|
1145
|
-
|
|
1585
|
+
_this3._errors.push({
|
|
1146
1586
|
err: new TestException({
|
|
1147
|
-
message:
|
|
1148
|
-
code:
|
|
1149
|
-
status: "
|
|
1587
|
+
message: "no tests given to be ran.",
|
|
1588
|
+
code: 1501,
|
|
1589
|
+
status: "no-tests"
|
|
1150
1590
|
})
|
|
1151
1591
|
});
|
|
1152
|
-
res(
|
|
1592
|
+
res(_this3.result);
|
|
1153
1593
|
}
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
}, {
|
|
1597
|
+
key: "_getTime",
|
|
1598
|
+
value: function _getTime(time) {
|
|
1599
|
+
return "".concat(time / 1000, " sec");
|
|
1600
|
+
}
|
|
1601
|
+
}, {
|
|
1602
|
+
key: "report",
|
|
1603
|
+
value: function report(detailed) {
|
|
1604
|
+
var _this4 = this;
|
|
1605
|
+
var time = 0;
|
|
1606
|
+
console.log("Finished.\n");
|
|
1607
|
+
var _loop = function _loop() {
|
|
1608
|
+
var testResult = _this4._results[i];
|
|
1609
|
+
var t = "(".concat(_this4._getTime(testResult.time), ")");
|
|
1610
|
+
if (detailed) {
|
|
1611
|
+
var message = "\n" + (i + 1) + ". ";
|
|
1612
|
+
var err = !(0, _base.isNullOrEmpty)(testResult.err) ? testResult.err.toString().split("\n") : [];
|
|
1613
|
+
err = err.map(function (msg, i) {
|
|
1614
|
+
return "\t".concat(i == err.length - 1 ? "".concat(fgYellow) : "".concat(fgGray, "error ").concat(testResult.err.code, ": ")).concat(msg).concat(reset);
|
|
1615
|
+
}).join("\n");
|
|
1616
|
+
if (!testResult.expected) {
|
|
1617
|
+
message += "".concat(bright).concat(fgWhite).concat(testResult.test, ": ").concat(fgMagenta, "expect not used").concat(reset, " ").concat(t);
|
|
1618
|
+
if (testResult.err) {
|
|
1619
|
+
message += "\n";
|
|
1620
|
+
message += "".concat(fgGray).concat(err, " ").concat(reset);
|
|
1621
|
+
}
|
|
1622
|
+
} else if (testResult.success) {
|
|
1623
|
+
message += "".concat(fgWhite).concat(testResult.test, ": ").concat(fgGreen, "passed").concat(reset, " ").concat(t);
|
|
1624
|
+
} else {
|
|
1625
|
+
message += "".concat(bright).concat(fgWhite).concat(testResult.test, ": ").concat(fgRed, "failed").concat(reset, " ").concat(t);
|
|
1626
|
+
message += "\n";
|
|
1627
|
+
message += "".concat(fgGray).concat(err, " ").concat(reset);
|
|
1628
|
+
}
|
|
1629
|
+
console.log(message);
|
|
1187
1630
|
}
|
|
1188
|
-
|
|
1631
|
+
time += testResult.time;
|
|
1632
|
+
};
|
|
1633
|
+
for (var i = 0; i < this._results.length; i++) {
|
|
1634
|
+
_loop();
|
|
1189
1635
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1636
|
+
if (detailed && this._errors.length) {
|
|
1637
|
+
console.log("Errors:");
|
|
1638
|
+
var _iterator = _createForOfIteratorHelper(this._errors),
|
|
1639
|
+
_step;
|
|
1640
|
+
try {
|
|
1641
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1642
|
+
var error = _step.value;
|
|
1643
|
+
if (error.index !== undefined) {
|
|
1644
|
+
console.log("".concat(error.index, ". ").concat(error.test, ": ").concat(error.err.innerException.toString()));
|
|
1645
|
+
} else {
|
|
1646
|
+
console.log("".concat(error.err.toString()));
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
} catch (err) {
|
|
1650
|
+
_iterator.e(err);
|
|
1651
|
+
} finally {
|
|
1652
|
+
_iterator.f();
|
|
1199
1653
|
}
|
|
1200
1654
|
}
|
|
1655
|
+
var text = (detailed ? "\n" : "") + "".concat(bright, "Number of tests: ").concat(reset).concat(this._passed + this._failed) + "\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._unknown > 0 ? ", ".concat(fgMagenta, " ").concat(this._unknown, " test(s) are unknown").concat(reset) : "") + "\n";
|
|
1656
|
+
console.log(text);
|
|
1657
|
+
}
|
|
1658
|
+
}, {
|
|
1659
|
+
key: "log",
|
|
1660
|
+
value: function log(filename) {
|
|
1661
|
+
var content = JSON.stringify({
|
|
1662
|
+
results: this._results,
|
|
1663
|
+
errors: this._errors
|
|
1664
|
+
}, null, "\t");
|
|
1665
|
+
if (filename == null) {
|
|
1666
|
+
var d = new Date();
|
|
1667
|
+
var year = d.getFullYear().toString().padStart(4, "0");
|
|
1668
|
+
var month = (d.getMonth() + 1).toString().padStart(2, "0");
|
|
1669
|
+
var day = d.getDate().toString().padStart(2, "0");
|
|
1670
|
+
var hours = d.getHours().toString().padStart(2, "0");
|
|
1671
|
+
var minutes = d.getMinutes().toString().padStart(2, "0");
|
|
1672
|
+
var seconds = d.getSeconds().toString().padStart(2, "0");
|
|
1673
|
+
filename = "test-".concat(year, "-").concat(month, "-").concat(day, "-").concat(hours).concat(minutes).concat(seconds, ".json");
|
|
1674
|
+
}
|
|
1675
|
+
var filepath = _path["default"].join(process.cwd(), filename);
|
|
1676
|
+
try {
|
|
1677
|
+
_fs["default"].writeFileSync(filepath, content);
|
|
1678
|
+
console.log("tests outcome wrote in ".concat(filename, "."));
|
|
1679
|
+
} catch (ex) {
|
|
1680
|
+
console.log("writing tests outcome failed.\n" + ex);
|
|
1681
|
+
}
|
|
1201
1682
|
}
|
|
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
|
-
|
|
1683
|
+
}], [{
|
|
1684
|
+
key: "start",
|
|
1685
|
+
value: function () {
|
|
1686
|
+
var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1687
|
+
var _ref;
|
|
1688
|
+
var tr,
|
|
1689
|
+
lastArg,
|
|
1690
|
+
detailed,
|
|
1691
|
+
_tests,
|
|
1692
|
+
i,
|
|
1693
|
+
t,
|
|
1694
|
+
result,
|
|
1695
|
+
_args4 = arguments;
|
|
1696
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1697
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1698
|
+
case 0:
|
|
1699
|
+
tr = new TestRunner();
|
|
1700
|
+
lastArg = (_ref = _args4.length - 1, _ref < 0 || _args4.length <= _ref ? undefined : _args4[_ref]);
|
|
1701
|
+
detailed = _args4.length && (0, _base.isBool)(lastArg) ? lastArg : false;
|
|
1702
|
+
_tests = [];
|
|
1703
|
+
for (i = 0; i < _args4.length; i++) {
|
|
1704
|
+
t = i < 0 || _args4.length <= i ? undefined : _args4[i];
|
|
1705
|
+
if (i != _args4.length - 1 || !(0, _base.isBool)(t)) {
|
|
1706
|
+
if ((0, _base.isIterable)(t)) {
|
|
1707
|
+
_tests = [].concat(_toConsumableArray(_tests), _toConsumableArray(t));
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
_context4.next = 7;
|
|
1712
|
+
return tr.run(_tests);
|
|
1713
|
+
case 7:
|
|
1714
|
+
result = _context4.sent;
|
|
1715
|
+
tr.report(detailed || result.failed > 0);
|
|
1716
|
+
return _context4.abrupt("return", {
|
|
1717
|
+
runner: tr,
|
|
1718
|
+
result: result
|
|
1719
|
+
});
|
|
1720
|
+
case 10:
|
|
1721
|
+
case "end":
|
|
1722
|
+
return _context4.stop();
|
|
1723
|
+
}
|
|
1724
|
+
}, _callee4);
|
|
1725
|
+
}));
|
|
1726
|
+
function start() {
|
|
1727
|
+
return _start.apply(this, arguments);
|
|
1728
|
+
}
|
|
1729
|
+
return start;
|
|
1730
|
+
}()
|
|
1731
|
+
}]);
|
|
1732
|
+
}();
|
|
1733
|
+
var _default = exports["default"] = TestRunner;
|