@locustjs/test 2.0.0 → 2.0.2
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/README.md +21 -8
- package/dist/index.js +2189 -1554
- package/package.json +5 -3
- package/rollup.config.js +11 -2
- package/src/Expect.js +69 -69
- package/src/Test.js +23 -7
- package/src/TestRunner.js +69 -20
- package/tests/index.js +12 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locustjs/test",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "This library provides a simple test runner for unit-testing.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/ironcodev/locustjs-test#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@locustjs/base": "^4.
|
|
31
|
-
"@locustjs/exception": "^2.
|
|
30
|
+
"@locustjs/base": "^4.5.2",
|
|
31
|
+
"@locustjs/exception": "^2.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@babel/preset-env": "^7.26.0",
|
|
35
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
34
36
|
"esm": "^3.2.25",
|
|
35
37
|
"rollup": "^4.29.1"
|
|
36
38
|
}
|
package/rollup.config.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
const { babel } = require("@rollup/plugin-babel");
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
input: "src/index.js",
|
|
5
|
+
plugins: [
|
|
6
|
+
babel({
|
|
7
|
+
babelHelpers: "bundled",
|
|
8
|
+
presets: ["@babel/preset-env"],
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
3
11
|
output: {
|
|
4
|
-
file: "dist/index.js",
|
|
12
|
+
file: "./dist/index.js",
|
|
5
13
|
format: "cjs",
|
|
6
|
-
}
|
|
14
|
+
},
|
|
15
|
+
external: ["@locustjs/base", "@locustjs/exception", "fs", "path"],
|
|
7
16
|
};
|
package/src/Expect.js
CHANGED
|
@@ -22,13 +22,13 @@ import TestException from "./TestException";
|
|
|
22
22
|
class Expect {
|
|
23
23
|
constructor(value) {
|
|
24
24
|
this.value = value;
|
|
25
|
-
this.
|
|
25
|
+
this._satisfied = false;
|
|
26
26
|
}
|
|
27
|
-
get
|
|
28
|
-
return this.
|
|
27
|
+
get satisfied() {
|
|
28
|
+
return this._satisfied;
|
|
29
29
|
}
|
|
30
30
|
toBe(value) {
|
|
31
|
-
this.
|
|
31
|
+
this._satisfied = true;
|
|
32
32
|
|
|
33
33
|
if (this.value === value) {
|
|
34
34
|
} else {
|
|
@@ -42,7 +42,7 @@ class Expect {
|
|
|
42
42
|
return this;
|
|
43
43
|
}
|
|
44
44
|
notToBe(value) {
|
|
45
|
-
this.
|
|
45
|
+
this._satisfied = true;
|
|
46
46
|
|
|
47
47
|
if (this.value === value) {
|
|
48
48
|
throw new TestException({
|
|
@@ -55,7 +55,7 @@ class Expect {
|
|
|
55
55
|
return this;
|
|
56
56
|
}
|
|
57
57
|
toBeGt(value) {
|
|
58
|
-
this.
|
|
58
|
+
this._satisfied = true;
|
|
59
59
|
|
|
60
60
|
if (this.value <= value) {
|
|
61
61
|
throw new TestException({
|
|
@@ -71,7 +71,7 @@ class Expect {
|
|
|
71
71
|
return this.toBeGt(value);
|
|
72
72
|
}
|
|
73
73
|
toBeGte(value) {
|
|
74
|
-
this.
|
|
74
|
+
this._satisfied = true;
|
|
75
75
|
|
|
76
76
|
if (this.value < value) {
|
|
77
77
|
throw new TestException({
|
|
@@ -87,7 +87,7 @@ class Expect {
|
|
|
87
87
|
return this.toBeGte(value);
|
|
88
88
|
}
|
|
89
89
|
toBeLt(value) {
|
|
90
|
-
this.
|
|
90
|
+
this._satisfied = true;
|
|
91
91
|
|
|
92
92
|
if (this.value >= value) {
|
|
93
93
|
throw new TestException({
|
|
@@ -103,7 +103,7 @@ class Expect {
|
|
|
103
103
|
return this.toBeLt(value);
|
|
104
104
|
}
|
|
105
105
|
toBeLte(value) {
|
|
106
|
-
this.
|
|
106
|
+
this._satisfied = true;
|
|
107
107
|
|
|
108
108
|
if (this.value > value) {
|
|
109
109
|
throw new TestException({
|
|
@@ -119,7 +119,7 @@ class Expect {
|
|
|
119
119
|
return this.toBeLte(value);
|
|
120
120
|
}
|
|
121
121
|
toBeBetween(n, m) {
|
|
122
|
-
this.
|
|
122
|
+
this._satisfied = true;
|
|
123
123
|
|
|
124
124
|
if (!(this.value >= n && this.value < m)) {
|
|
125
125
|
throw new TestException({
|
|
@@ -132,7 +132,7 @@ class Expect {
|
|
|
132
132
|
return this;
|
|
133
133
|
}
|
|
134
134
|
notToBeBetween(n, m) {
|
|
135
|
-
this.
|
|
135
|
+
this._satisfied = true;
|
|
136
136
|
|
|
137
137
|
if (this.value >= n && this.value < m) {
|
|
138
138
|
throw new TestException({
|
|
@@ -145,7 +145,7 @@ class Expect {
|
|
|
145
145
|
return this;
|
|
146
146
|
}
|
|
147
147
|
toBeOfType(type) {
|
|
148
|
-
this.
|
|
148
|
+
this._satisfied = true;
|
|
149
149
|
|
|
150
150
|
if (typeof this.value !== type) {
|
|
151
151
|
throw new TestException({
|
|
@@ -158,7 +158,7 @@ class Expect {
|
|
|
158
158
|
return this;
|
|
159
159
|
}
|
|
160
160
|
notToBeOfType(type) {
|
|
161
|
-
this.
|
|
161
|
+
this._satisfied = true;
|
|
162
162
|
|
|
163
163
|
if (typeof this.value === type) {
|
|
164
164
|
throw new TestException({
|
|
@@ -171,7 +171,7 @@ class Expect {
|
|
|
171
171
|
return this;
|
|
172
172
|
}
|
|
173
173
|
toBeString() {
|
|
174
|
-
this.
|
|
174
|
+
this._satisfied = true;
|
|
175
175
|
|
|
176
176
|
if (!isString(this.value)) {
|
|
177
177
|
throw new TestException({
|
|
@@ -184,7 +184,7 @@ class Expect {
|
|
|
184
184
|
return this;
|
|
185
185
|
}
|
|
186
186
|
notToBeString() {
|
|
187
|
-
this.
|
|
187
|
+
this._satisfied = true;
|
|
188
188
|
|
|
189
189
|
if (isString(this.value)) {
|
|
190
190
|
throw new TestException({
|
|
@@ -197,7 +197,7 @@ class Expect {
|
|
|
197
197
|
return this;
|
|
198
198
|
}
|
|
199
199
|
toBeSomeString() {
|
|
200
|
-
this.
|
|
200
|
+
this._satisfied = true;
|
|
201
201
|
if (!isSomeString(this.value)) {
|
|
202
202
|
throw new TestException({
|
|
203
203
|
message: `${this.value} is not some string`,
|
|
@@ -209,7 +209,7 @@ class Expect {
|
|
|
209
209
|
return this;
|
|
210
210
|
}
|
|
211
211
|
notToBeSomeString() {
|
|
212
|
-
this.
|
|
212
|
+
this._satisfied = true;
|
|
213
213
|
|
|
214
214
|
if (isSomeString(this.value)) {
|
|
215
215
|
throw new TestException({
|
|
@@ -222,7 +222,7 @@ class Expect {
|
|
|
222
222
|
return this;
|
|
223
223
|
}
|
|
224
224
|
toBeNumber() {
|
|
225
|
-
this.
|
|
225
|
+
this._satisfied = true;
|
|
226
226
|
|
|
227
227
|
if (!isNumber(this.value)) {
|
|
228
228
|
throw new TestException({
|
|
@@ -235,7 +235,7 @@ class Expect {
|
|
|
235
235
|
return this;
|
|
236
236
|
}
|
|
237
237
|
notToBeNumber() {
|
|
238
|
-
this.
|
|
238
|
+
this._satisfied = true;
|
|
239
239
|
|
|
240
240
|
if (isNumber(this.value)) {
|
|
241
241
|
throw new TestException({
|
|
@@ -248,7 +248,7 @@ class Expect {
|
|
|
248
248
|
return this;
|
|
249
249
|
}
|
|
250
250
|
toBeDate() {
|
|
251
|
-
this.
|
|
251
|
+
this._satisfied = true;
|
|
252
252
|
|
|
253
253
|
if (!isDate(this.value)) {
|
|
254
254
|
throw new TestException({
|
|
@@ -261,7 +261,7 @@ class Expect {
|
|
|
261
261
|
return this;
|
|
262
262
|
}
|
|
263
263
|
notToBeDate() {
|
|
264
|
-
this.
|
|
264
|
+
this._satisfied = true;
|
|
265
265
|
|
|
266
266
|
if (isDate(this.value)) {
|
|
267
267
|
throw new TestException({
|
|
@@ -274,7 +274,7 @@ class Expect {
|
|
|
274
274
|
return this;
|
|
275
275
|
}
|
|
276
276
|
toBeBool() {
|
|
277
|
-
this.
|
|
277
|
+
this._satisfied = true;
|
|
278
278
|
|
|
279
279
|
if (!isBool(this.value)) {
|
|
280
280
|
throw new TestException({
|
|
@@ -287,7 +287,7 @@ class Expect {
|
|
|
287
287
|
return this;
|
|
288
288
|
}
|
|
289
289
|
notToBeBool() {
|
|
290
|
-
this.
|
|
290
|
+
this._satisfied = true;
|
|
291
291
|
|
|
292
292
|
if (isBool(this.value)) {
|
|
293
293
|
throw new TestException({
|
|
@@ -300,7 +300,7 @@ class Expect {
|
|
|
300
300
|
return this;
|
|
301
301
|
}
|
|
302
302
|
toBeBasicType() {
|
|
303
|
-
this.
|
|
303
|
+
this._satisfied = true;
|
|
304
304
|
|
|
305
305
|
if (!isBasic(this.value)) {
|
|
306
306
|
throw new TestException({
|
|
@@ -313,7 +313,7 @@ class Expect {
|
|
|
313
313
|
return this;
|
|
314
314
|
}
|
|
315
315
|
notToBeBasicType() {
|
|
316
|
-
this.
|
|
316
|
+
this._satisfied = true;
|
|
317
317
|
|
|
318
318
|
if (isBasic(this.value)) {
|
|
319
319
|
throw new TestException({
|
|
@@ -326,7 +326,7 @@ class Expect {
|
|
|
326
326
|
return this;
|
|
327
327
|
}
|
|
328
328
|
toBePrimitive() {
|
|
329
|
-
this.
|
|
329
|
+
this._satisfied = true;
|
|
330
330
|
|
|
331
331
|
if (!isPrimitive(this.value)) {
|
|
332
332
|
throw new TestException({
|
|
@@ -339,7 +339,7 @@ class Expect {
|
|
|
339
339
|
return this;
|
|
340
340
|
}
|
|
341
341
|
notToBePrimitive() {
|
|
342
|
-
this.
|
|
342
|
+
this._satisfied = true;
|
|
343
343
|
|
|
344
344
|
if (isPrimitive(this.value)) {
|
|
345
345
|
throw new TestException({
|
|
@@ -352,7 +352,7 @@ class Expect {
|
|
|
352
352
|
return this;
|
|
353
353
|
}
|
|
354
354
|
toBeEmpty() {
|
|
355
|
-
this.
|
|
355
|
+
this._satisfied = true;
|
|
356
356
|
|
|
357
357
|
if (!isEmpty(this.value)) {
|
|
358
358
|
throw new TestException({
|
|
@@ -365,7 +365,7 @@ class Expect {
|
|
|
365
365
|
return this;
|
|
366
366
|
}
|
|
367
367
|
notToBeEmpty() {
|
|
368
|
-
this.
|
|
368
|
+
this._satisfied = true;
|
|
369
369
|
|
|
370
370
|
if (isEmpty(this.value)) {
|
|
371
371
|
throw new TestException({
|
|
@@ -378,7 +378,7 @@ class Expect {
|
|
|
378
378
|
return this;
|
|
379
379
|
}
|
|
380
380
|
toBeObject() {
|
|
381
|
-
this.
|
|
381
|
+
this._satisfied = true;
|
|
382
382
|
|
|
383
383
|
if (!isObject(this.value)) {
|
|
384
384
|
throw new TestException({
|
|
@@ -391,7 +391,7 @@ class Expect {
|
|
|
391
391
|
return this;
|
|
392
392
|
}
|
|
393
393
|
notToBeObject() {
|
|
394
|
-
this.
|
|
394
|
+
this._satisfied = true;
|
|
395
395
|
|
|
396
396
|
if (isObject(this.value)) {
|
|
397
397
|
throw new TestException({
|
|
@@ -404,7 +404,7 @@ class Expect {
|
|
|
404
404
|
return this;
|
|
405
405
|
}
|
|
406
406
|
toBeSomeObject() {
|
|
407
|
-
this.
|
|
407
|
+
this._satisfied = true;
|
|
408
408
|
|
|
409
409
|
if (!isSomeObject(this.value)) {
|
|
410
410
|
throw new TestException({
|
|
@@ -417,7 +417,7 @@ class Expect {
|
|
|
417
417
|
return this;
|
|
418
418
|
}
|
|
419
419
|
notToBeSomeObject() {
|
|
420
|
-
this.
|
|
420
|
+
this._satisfied = true;
|
|
421
421
|
|
|
422
422
|
if (isSomeObject(this.value)) {
|
|
423
423
|
throw new TestException({
|
|
@@ -430,7 +430,7 @@ class Expect {
|
|
|
430
430
|
return this;
|
|
431
431
|
}
|
|
432
432
|
toBeFunction() {
|
|
433
|
-
this.
|
|
433
|
+
this._satisfied = true;
|
|
434
434
|
|
|
435
435
|
if (!isFunction(this.value)) {
|
|
436
436
|
throw new TestException({
|
|
@@ -443,7 +443,7 @@ class Expect {
|
|
|
443
443
|
return this;
|
|
444
444
|
}
|
|
445
445
|
notToBeFunction() {
|
|
446
|
-
this.
|
|
446
|
+
this._satisfied = true;
|
|
447
447
|
|
|
448
448
|
if (isFunction(this.value)) {
|
|
449
449
|
throw new TestException({
|
|
@@ -456,7 +456,7 @@ class Expect {
|
|
|
456
456
|
return this;
|
|
457
457
|
}
|
|
458
458
|
toBeNumeric() {
|
|
459
|
-
this.
|
|
459
|
+
this._satisfied = true;
|
|
460
460
|
|
|
461
461
|
if (!isNumeric(this.value)) {
|
|
462
462
|
throw new TestException({
|
|
@@ -469,7 +469,7 @@ class Expect {
|
|
|
469
469
|
return this;
|
|
470
470
|
}
|
|
471
471
|
notToBeNumeric() {
|
|
472
|
-
this.
|
|
472
|
+
this._satisfied = true;
|
|
473
473
|
|
|
474
474
|
if (isNumeric(this.value)) {
|
|
475
475
|
throw new TestException({
|
|
@@ -482,7 +482,7 @@ class Expect {
|
|
|
482
482
|
return this;
|
|
483
483
|
}
|
|
484
484
|
toBeArray() {
|
|
485
|
-
this.
|
|
485
|
+
this._satisfied = true;
|
|
486
486
|
|
|
487
487
|
if (!isArray(this.value)) {
|
|
488
488
|
throw new TestException({
|
|
@@ -495,7 +495,7 @@ class Expect {
|
|
|
495
495
|
return this;
|
|
496
496
|
}
|
|
497
497
|
notToBeArray() {
|
|
498
|
-
this.
|
|
498
|
+
this._satisfied = true;
|
|
499
499
|
|
|
500
500
|
if (isArray(this.value)) {
|
|
501
501
|
throw new TestException({
|
|
@@ -508,7 +508,7 @@ class Expect {
|
|
|
508
508
|
return this;
|
|
509
509
|
}
|
|
510
510
|
toBeSomeArray() {
|
|
511
|
-
this.
|
|
511
|
+
this._satisfied = true;
|
|
512
512
|
|
|
513
513
|
if (!isSomeArray(this.value)) {
|
|
514
514
|
throw new TestException({
|
|
@@ -521,7 +521,7 @@ class Expect {
|
|
|
521
521
|
return this;
|
|
522
522
|
}
|
|
523
523
|
notToBeSomeArray() {
|
|
524
|
-
this.
|
|
524
|
+
this._satisfied = true;
|
|
525
525
|
|
|
526
526
|
if (!isArray(this.value)) {
|
|
527
527
|
throw new TestException({
|
|
@@ -541,7 +541,7 @@ class Expect {
|
|
|
541
541
|
return this;
|
|
542
542
|
}
|
|
543
543
|
toBeIterable() {
|
|
544
|
-
this.
|
|
544
|
+
this._satisfied = true;
|
|
545
545
|
|
|
546
546
|
if (!isIterable(this.value)) {
|
|
547
547
|
throw new TestException({
|
|
@@ -554,7 +554,7 @@ class Expect {
|
|
|
554
554
|
return this;
|
|
555
555
|
}
|
|
556
556
|
notToBeIterable() {
|
|
557
|
-
this.
|
|
557
|
+
this._satisfied = true;
|
|
558
558
|
|
|
559
559
|
if (isIterable(this.value)) {
|
|
560
560
|
throw new TestException({
|
|
@@ -567,7 +567,7 @@ class Expect {
|
|
|
567
567
|
return this;
|
|
568
568
|
}
|
|
569
569
|
toBeSubClassOf(type) {
|
|
570
|
-
this.
|
|
570
|
+
this._satisfied = true;
|
|
571
571
|
|
|
572
572
|
if (!isSubClassOf(this.value, type)) {
|
|
573
573
|
throw new TestException({
|
|
@@ -580,7 +580,7 @@ class Expect {
|
|
|
580
580
|
return this;
|
|
581
581
|
}
|
|
582
582
|
notToBeSubClassOf(type) {
|
|
583
|
-
this.
|
|
583
|
+
this._satisfied = true;
|
|
584
584
|
|
|
585
585
|
if (isSubClassOf(this.value, type)) {
|
|
586
586
|
throw new TestException({
|
|
@@ -593,7 +593,7 @@ class Expect {
|
|
|
593
593
|
return this;
|
|
594
594
|
}
|
|
595
595
|
toBeInstanceOf(type) {
|
|
596
|
-
this.
|
|
596
|
+
this._satisfied = true;
|
|
597
597
|
|
|
598
598
|
if (!(this.value instanceof type)) {
|
|
599
599
|
throw new TestException({
|
|
@@ -606,7 +606,7 @@ class Expect {
|
|
|
606
606
|
return this;
|
|
607
607
|
}
|
|
608
608
|
notToBeInstanceOf(type) {
|
|
609
|
-
this.
|
|
609
|
+
this._satisfied = true;
|
|
610
610
|
|
|
611
611
|
if (this.value instanceof type) {
|
|
612
612
|
throw new TestException({
|
|
@@ -619,7 +619,7 @@ class Expect {
|
|
|
619
619
|
return this;
|
|
620
620
|
}
|
|
621
621
|
toMatch(pattern, flags) {
|
|
622
|
-
this.
|
|
622
|
+
this._satisfied = true;
|
|
623
623
|
|
|
624
624
|
const r = new RegExp(pattern, flags);
|
|
625
625
|
|
|
@@ -634,7 +634,7 @@ class Expect {
|
|
|
634
634
|
return this;
|
|
635
635
|
}
|
|
636
636
|
notToMatch(pattern, flags) {
|
|
637
|
-
this.
|
|
637
|
+
this._satisfied = true;
|
|
638
638
|
|
|
639
639
|
const r = new RegExp(pattern, flags);
|
|
640
640
|
|
|
@@ -649,7 +649,7 @@ class Expect {
|
|
|
649
649
|
return this;
|
|
650
650
|
}
|
|
651
651
|
doesNotMatch(pattern, flags) {
|
|
652
|
-
this.
|
|
652
|
+
this._satisfied = true;
|
|
653
653
|
|
|
654
654
|
const r = new RegExp(pattern, flags);
|
|
655
655
|
|
|
@@ -664,7 +664,7 @@ class Expect {
|
|
|
664
664
|
return this;
|
|
665
665
|
}
|
|
666
666
|
toBeDefined() {
|
|
667
|
-
this.
|
|
667
|
+
this._satisfied = true;
|
|
668
668
|
|
|
669
669
|
if (this.value === undefined) {
|
|
670
670
|
throw new TestException({
|
|
@@ -677,7 +677,7 @@ class Expect {
|
|
|
677
677
|
return this;
|
|
678
678
|
}
|
|
679
679
|
notToBeDefined() {
|
|
680
|
-
this.
|
|
680
|
+
this._satisfied = true;
|
|
681
681
|
|
|
682
682
|
if (this.value !== undefined) {
|
|
683
683
|
throw new TestException({
|
|
@@ -690,7 +690,7 @@ class Expect {
|
|
|
690
690
|
return this;
|
|
691
691
|
}
|
|
692
692
|
toBeUndefined() {
|
|
693
|
-
this.
|
|
693
|
+
this._satisfied = true;
|
|
694
694
|
|
|
695
695
|
if (this.value !== undefined) {
|
|
696
696
|
throw new TestException({
|
|
@@ -703,7 +703,7 @@ class Expect {
|
|
|
703
703
|
return this;
|
|
704
704
|
}
|
|
705
705
|
notToBeUndefined() {
|
|
706
|
-
this.
|
|
706
|
+
this._satisfied = true;
|
|
707
707
|
|
|
708
708
|
if (this.value === undefined) {
|
|
709
709
|
throw new TestException({
|
|
@@ -716,7 +716,7 @@ class Expect {
|
|
|
716
716
|
return this;
|
|
717
717
|
}
|
|
718
718
|
toBeNull() {
|
|
719
|
-
this.
|
|
719
|
+
this._satisfied = true;
|
|
720
720
|
|
|
721
721
|
if (this.value !== null) {
|
|
722
722
|
throw new TestException({
|
|
@@ -729,7 +729,7 @@ class Expect {
|
|
|
729
729
|
return this;
|
|
730
730
|
}
|
|
731
731
|
notToBeNull() {
|
|
732
|
-
this.
|
|
732
|
+
this._satisfied = true;
|
|
733
733
|
|
|
734
734
|
if (this.value === null) {
|
|
735
735
|
throw new TestException({
|
|
@@ -742,7 +742,7 @@ class Expect {
|
|
|
742
742
|
return this;
|
|
743
743
|
}
|
|
744
744
|
toBeNullOrUndefined() {
|
|
745
|
-
this.
|
|
745
|
+
this._satisfied = true;
|
|
746
746
|
|
|
747
747
|
if (this.value == null) {
|
|
748
748
|
} else {
|
|
@@ -756,7 +756,7 @@ class Expect {
|
|
|
756
756
|
return this;
|
|
757
757
|
}
|
|
758
758
|
notToBeNullOrUndefined() {
|
|
759
|
-
this.
|
|
759
|
+
this._satisfied = true;
|
|
760
760
|
|
|
761
761
|
if (this.value == null) {
|
|
762
762
|
throw new TestException({
|
|
@@ -769,7 +769,7 @@ class Expect {
|
|
|
769
769
|
return this;
|
|
770
770
|
}
|
|
771
771
|
toBeEmptyArray() {
|
|
772
|
-
this.
|
|
772
|
+
this._satisfied = true;
|
|
773
773
|
|
|
774
774
|
if (isSomeArray(this.value)) {
|
|
775
775
|
throw new TestException({
|
|
@@ -782,7 +782,7 @@ class Expect {
|
|
|
782
782
|
return this;
|
|
783
783
|
}
|
|
784
784
|
toBeValid(fnValidation) {
|
|
785
|
-
this.
|
|
785
|
+
this._satisfied = true;
|
|
786
786
|
|
|
787
787
|
if (!isFunction(fnValidation)) {
|
|
788
788
|
throw new TestException({
|
|
@@ -802,7 +802,7 @@ class Expect {
|
|
|
802
802
|
return this;
|
|
803
803
|
}
|
|
804
804
|
notToBeValid(fnValidation) {
|
|
805
|
-
this.
|
|
805
|
+
this._satisfied = true;
|
|
806
806
|
|
|
807
807
|
if (!isFunction(fnValidation)) {
|
|
808
808
|
throw new TestException({
|
|
@@ -822,7 +822,7 @@ class Expect {
|
|
|
822
822
|
return this;
|
|
823
823
|
}
|
|
824
824
|
toThrow(ex, shape = false, strict = false) {
|
|
825
|
-
this.
|
|
825
|
+
this._satisfied = true;
|
|
826
826
|
|
|
827
827
|
if (!isFunction(this.value)) {
|
|
828
828
|
throw new TestException({
|
|
@@ -899,7 +899,7 @@ class Expect {
|
|
|
899
899
|
return this;
|
|
900
900
|
}
|
|
901
901
|
notToThrow(ex, shape = false, strict = false) {
|
|
902
|
-
this.
|
|
902
|
+
this._satisfied = true;
|
|
903
903
|
|
|
904
904
|
if (!isFunction(this.value)) {
|
|
905
905
|
throw new TestException({
|
|
@@ -980,7 +980,7 @@ class Expect {
|
|
|
980
980
|
return this;
|
|
981
981
|
}
|
|
982
982
|
async toThrowAsync(ex, shape = false, strict = false) {
|
|
983
|
-
this.
|
|
983
|
+
this._satisfied = true;
|
|
984
984
|
|
|
985
985
|
if (!isFunction(this.value)) {
|
|
986
986
|
throw new TestException({
|
|
@@ -1057,7 +1057,7 @@ class Expect {
|
|
|
1057
1057
|
return this;
|
|
1058
1058
|
}
|
|
1059
1059
|
async notToThrowAsync(ex, shape = false, strict = false) {
|
|
1060
|
-
this.
|
|
1060
|
+
this._satisfied = true;
|
|
1061
1061
|
|
|
1062
1062
|
if (!isFunction(this.value)) {
|
|
1063
1063
|
throw new TestException({
|
|
@@ -1138,7 +1138,7 @@ class Expect {
|
|
|
1138
1138
|
return this;
|
|
1139
1139
|
}
|
|
1140
1140
|
toBeTruthy() {
|
|
1141
|
-
this.
|
|
1141
|
+
this._satisfied = true;
|
|
1142
1142
|
|
|
1143
1143
|
if (this.value) {
|
|
1144
1144
|
} else {
|
|
@@ -1155,7 +1155,7 @@ class Expect {
|
|
|
1155
1155
|
return this.toBeTruthy();
|
|
1156
1156
|
}
|
|
1157
1157
|
toBeFalsy() {
|
|
1158
|
-
this.
|
|
1158
|
+
this._satisfied = true;
|
|
1159
1159
|
|
|
1160
1160
|
if (!this.value) {
|
|
1161
1161
|
} else {
|
|
@@ -1172,7 +1172,7 @@ class Expect {
|
|
|
1172
1172
|
return this.toBeFalsy();
|
|
1173
1173
|
}
|
|
1174
1174
|
toBeNaN() {
|
|
1175
|
-
this.
|
|
1175
|
+
this._satisfied = true;
|
|
1176
1176
|
|
|
1177
1177
|
if (isNaN(this.value)) {
|
|
1178
1178
|
} else {
|
|
@@ -1186,7 +1186,7 @@ class Expect {
|
|
|
1186
1186
|
return this;
|
|
1187
1187
|
}
|
|
1188
1188
|
notToBeNaN() {
|
|
1189
|
-
this.
|
|
1189
|
+
this._satisfied = true;
|
|
1190
1190
|
|
|
1191
1191
|
if (!isNaN(this.value)) {
|
|
1192
1192
|
} else {
|
package/src/Test.js
CHANGED
|
@@ -14,12 +14,28 @@ class Test {
|
|
|
14
14
|
if (isFunction(this.fn)) {
|
|
15
15
|
const _expect = new Expect();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
const
|
|
17
|
+
function expectProvider(fn) {
|
|
18
|
+
const expect = function (x) {
|
|
19
19
|
_expect.value = x;
|
|
20
20
|
|
|
21
21
|
return _expect;
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
|
+
const fnStr = fn.toString();
|
|
24
|
+
const wrapper = new Function(
|
|
25
|
+
"expect",
|
|
26
|
+
`
|
|
27
|
+
return function() {
|
|
28
|
+
return (${fnStr})();
|
|
29
|
+
};
|
|
30
|
+
`,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return wrapper(expect);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const wrappedFn = expectProvider(this.fn);
|
|
38
|
+
const _result = wrappedFn();
|
|
23
39
|
|
|
24
40
|
if (_result && isFunction(_result.then)) {
|
|
25
41
|
_result
|
|
@@ -29,7 +45,7 @@ class Test {
|
|
|
29
45
|
test: this.name,
|
|
30
46
|
result,
|
|
31
47
|
time: new Date() - start,
|
|
32
|
-
|
|
48
|
+
satisfied: _expect.satisfied,
|
|
33
49
|
});
|
|
34
50
|
})
|
|
35
51
|
.catch((ex) => {
|
|
@@ -37,7 +53,7 @@ class Test {
|
|
|
37
53
|
success: false,
|
|
38
54
|
test: this.name,
|
|
39
55
|
time: new Date() - start,
|
|
40
|
-
|
|
56
|
+
satisfied: _expect.satisfied,
|
|
41
57
|
err: new TestException({
|
|
42
58
|
message: `test '${this.name}' failed.`,
|
|
43
59
|
code: 501,
|
|
@@ -52,7 +68,7 @@ class Test {
|
|
|
52
68
|
test: this.name,
|
|
53
69
|
time: new Date() - start,
|
|
54
70
|
result: _result,
|
|
55
|
-
|
|
71
|
+
satisfied: _expect.satisfied,
|
|
56
72
|
});
|
|
57
73
|
}
|
|
58
74
|
} catch (ex) {
|
|
@@ -60,7 +76,7 @@ class Test {
|
|
|
60
76
|
success: false,
|
|
61
77
|
test: this.name,
|
|
62
78
|
time: new Date() - start,
|
|
63
|
-
|
|
79
|
+
satisfied: _expect.satisfied,
|
|
64
80
|
err: new TestException({
|
|
65
81
|
message: `test '${this.name}' failed.`,
|
|
66
82
|
code: 501,
|