@locustjs/test 1.4.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/index.cjs.js CHANGED
@@ -1,1155 +1,1733 @@
1
- import { equals, isString, isNumber, isDate, isBool, isBasic, isPrimitive, isEmpty, isSomeString, isObject, isSomeObject, isFunction, isNumeric, isArray, isIterable, isSomeArray, isSubClassOf } from "@locustjs/base";
2
- import { Exception } from "@locustjs/exception";
3
- import fs from "fs";
4
- import path from "path";
5
- class Expect {
6
- constructor(value) {
7
- this.value = value;
8
- }
9
- toBe(value) {
10
- if (this.value === value) {} else {
11
- throw new Exception({
12
- message: `${this.value} is not equal to ${value}`,
13
- code: 1000,
14
- status: "not-eq"
15
- });
16
- }
17
- return this;
18
- }
19
- toBeGt(value) {
20
- if (this.value <= value) {
21
- throw new Exception({
22
- message: `${this.value} is not greater than ${value}`,
23
- code: 1001,
24
- status: "lte"
25
- });
26
- }
27
- return this;
28
- }
29
- toBeGreaterThan(value) {
30
- return this.toBeGt(value);
31
- }
32
- toBeGte(value) {
33
- if (this.value < value) {
34
- throw new Exception({
35
- message: `${this.value} is not greater than or equal to ${value}`,
36
- code: 1002,
37
- status: "lt"
38
- });
39
- }
40
- return this;
41
- }
42
- toBeGreaterThanOrEqualTo(value) {
43
- return this.toBeGte(value);
44
- }
45
- toBeLt(value) {
46
- if (this.value >= value) {
47
- throw new Exception({
48
- message: `${this.value} is not less than ${value}`,
49
- code: 1003,
50
- status: "gte"
51
- });
52
- }
53
- return this;
54
- }
55
- toBeLowerThan(value) {
56
- return this.toBeLt(value);
57
- }
58
- toBeLte(value) {
59
- if (this.value > value) {
60
- throw new Exception({
61
- message: `${this.value} is not less than or equal to ${value}`,
62
- code: 1004,
63
- status: "gt"
64
- });
65
- }
66
- return this;
67
- }
68
- toBeLowerThanOrEqualTo(value) {
69
- return this.toBeLte(value);
70
- }
71
- toBeBetween(n, m) {
72
- if (!(this.value >= n && this.value < m)) {
73
- throw new Exception({
74
- message: `${this.value} is not between ${n} and ${m}`,
75
- code: 1024,
76
- status: "between"
77
- });
78
- }
79
- return this;
80
- }
81
- toBeOfType(type) {
82
- if (typeof this.value !== type) {
83
- throw new Exception({
84
- message: `${this.value} is not of type ${type}`,
85
- code: 1025,
86
- status: "of-type"
87
- });
88
- }
89
- return this;
90
- }
91
- toBeString() {
92
- if (!isString(this.value)) {
93
- throw new Exception({
94
- message: `${this.value} is not string`,
95
- code: 1026,
96
- status: "is-string"
97
- });
98
- }
99
- return this;
100
- }
101
- toBeSomeString() {
102
- if (!isSomeString(this.value)) {
103
- throw new Exception({
104
- message: `${this.value} is not some string`,
105
- code: 1027,
106
- status: "is-some-string"
107
- });
108
- }
109
- return this;
110
- }
111
- toBeNumber() {
112
- if (!isNumber(this.value)) {
113
- throw new Exception({
114
- message: `${this.value} is not number`,
115
- code: 1028,
116
- status: "is-number"
117
- });
118
- }
119
- return this;
120
- }
121
- toBeDate() {
122
- if (!isDate(this.value)) {
123
- throw new Exception({
124
- message: `${this.value} is not date`,
125
- code: 1029,
126
- status: "is-date"
127
- });
128
- }
129
- return this;
130
- }
131
- toBeBool() {
132
- if (!isBool(this.value)) {
133
- throw new Exception({
134
- message: `${this.value} is not bool`,
135
- code: 1030,
136
- status: "is-bool"
137
- });
138
- }
139
- return this;
140
- }
141
- toBeBasicType() {
142
- if (!isBasic(this.value)) {
143
- throw new Exception({
144
- message: `${this.value} is not basic type`,
145
- code: 1031,
146
- status: "is-basic-type"
147
- });
148
- }
149
- return this;
150
- }
151
- toBePrimitive() {
152
- if (!isPrimitive(this.value)) {
153
- throw new Exception({
154
- message: `${this.value} is not primitive type`,
155
- code: 1032,
156
- status: "is-primitive"
157
- });
158
- }
159
- return this;
160
- }
161
- toBeEmpty() {
162
- if (!isEmpty(this.value)) {
163
- throw new Exception({
164
- message: `${this.value} is not empty`,
165
- code: 1033,
166
- status: "is-empty"
167
- });
168
- }
169
- return this;
170
- }
171
- toBeObject() {
172
- if (!isObject(this.value)) {
173
- throw new Exception({
174
- message: `${this.value} is not object`,
175
- code: 1034,
176
- status: "is-object"
177
- });
178
- }
179
- return this;
180
- }
181
- toBeSomeObject() {
182
- if (!isSomeObject(this.value)) {
183
- throw new Exception({
184
- message: `${this.value} is not some object`,
185
- code: 1035,
186
- status: "is-some-object"
187
- });
188
- }
189
- return this;
190
- }
191
- toBeFunction() {
192
- if (!isFunction(this.value)) {
193
- throw new Exception({
194
- message: `${this.value} is not function`,
195
- code: 1036,
196
- status: "is-function"
197
- });
198
- }
199
- return this;
200
- }
201
- toBeNumeric() {
202
- if (!isNumeric(this.value)) {
203
- throw new Exception({
204
- message: `${this.value} is not numeric`,
205
- code: 1037,
206
- status: "is-numeric"
207
- });
208
- }
209
- return this;
210
- }
211
- toBeArray() {
212
- if (!isArray(this.value)) {
213
- throw new Exception({
214
- message: `${this.value} is not array`,
215
- code: 1038,
216
- status: "is-array"
217
- });
218
- }
219
- return this;
220
- }
221
- toBeSomeArray() {
222
- if (!isSomeArray(this.value)) {
223
- throw new Exception({
224
- message: `${this.value} is not some array`,
225
- code: 1039,
226
- status: "is-some-array"
227
- });
228
- }
229
- return this;
230
- }
231
- toBeIterable() {
232
- if (!isIterable(this.value)) {
233
- throw new Exception({
234
- message: `${this.value} is not iterable`,
235
- code: 1040,
236
- status: "is-iterable"
237
- });
238
- }
239
- return this;
240
- }
241
- toBeSubClassOf(type) {
242
- if (!isSubClassOf(this.value, type)) {
243
- throw new Exception({
244
- message: `${this.value} is not subclass of ${type}`,
245
- code: 1041,
246
- status: "is-subclass-of"
247
- });
248
- }
249
- return this;
250
- }
251
- toBeInstanceOf(type) {
252
- if (!(this.value instanceof type)) {
253
- throw new Exception({
254
- message: `${this.value} is not instance of ${type}`,
255
- code: 1042,
256
- status: "instanceof"
257
- });
258
- }
259
- return this;
260
- }
261
- toMatch(pattern, flags) {
262
- const r = new RegExp(pattern, flags);
263
- if (!r.test(this.value)) {
264
- throw new Exception({
265
- message: `${this.value} does not match ${pattern}`,
266
- code: 1043,
267
- status: "match"
268
- });
269
- }
270
- return this;
271
- }
272
- notToBe(value) {
273
- if (this.value === value) {
274
- throw new Exception({
275
- message: `${value} is equal to ${this.value}`,
276
- code: 1005,
277
- status: "eq"
278
- });
279
- }
280
- return this;
281
- }
282
- toBeDefined() {
283
- if (this.value === undefined) {
284
- throw new Exception({
285
- message: `value is undefined`,
286
- code: 1006,
287
- status: "undefined"
288
- });
289
- }
290
- return this;
291
- }
292
- toBeUndefined() {
293
- if (this.value !== undefined) {
294
- throw new Exception({
295
- message: `value is defined`,
296
- code: 1007,
297
- status: "defined"
298
- });
299
- }
300
- return this;
301
- }
302
- toBeNull() {
303
- if (this.value !== null) {
304
- throw new Exception({
305
- message: `value is not null`,
306
- code: 1008,
307
- status: "not-null"
308
- });
309
- }
310
- return this;
311
- }
312
- notToBeNull() {
313
- if (this.value === null) {
314
- throw new Exception({
315
- message: `value is null`,
316
- code: 1009,
317
- status: "null"
318
- });
319
- }
320
- return this;
321
- }
322
- toBeNullOrUndefined() {
323
- if (this.value == null) {} else {
324
- throw new Exception({
325
- message: `value is not null/undefined`,
326
- code: 1010,
327
- status: "not-null-or-undefined"
328
- });
329
- }
330
- return this;
331
- }
332
- notToBeNullOrUndefined() {
333
- if (this.value == null) {
334
- throw new Exception({
335
- message: `value is null/undefined`,
336
- code: 1011,
337
- status: "null-or-undefined"
338
- });
339
- }
340
- return this;
341
- }
342
- notToBeBetween(n, m) {
343
- if (this.value >= n && this.value < m) {
344
- throw new Exception({
345
- message: `${this.value} is between ${n} and ${m}`,
346
- code: 1044,
347
- status: "not-between"
348
- });
349
- }
350
- return this;
351
- }
352
- notToBeOfType(type) {
353
- if (typeof this.value === type) {
354
- throw new Exception({
355
- message: `${this.value} is of type ${type}`,
356
- code: 1045,
357
- status: "not-oftype"
358
- });
359
- }
360
- return this;
361
- }
362
- notToBeString() {
363
- if (isString(this.value)) {
364
- throw new Exception({
365
- message: `${this.value} is string`,
366
- code: 1046,
367
- status: "not-is-string"
368
- });
369
- }
370
- return this;
371
- }
372
- notToBeSomeString() {
373
- if (isSomeString(this.value)) {
374
- throw new Exception({
375
- message: `${this.value} is some string`,
376
- code: 1047,
377
- status: "not-is-some-string"
378
- });
379
- }
380
- return this;
381
- }
382
- notToBeNumber() {
383
- if (isNumber(this.value)) {
384
- throw new Exception({
385
- message: `${this.value} is number`,
386
- code: 1048,
387
- status: "not-is-number"
388
- });
389
- }
390
- return this;
391
- }
392
- notToBeDate() {
393
- if (isDate(this.value)) {
394
- throw new Exception({
395
- message: `${this.value} is date`,
396
- code: 1049,
397
- status: "not-is-date"
398
- });
399
- }
400
- return this;
401
- }
402
- notToBeBool() {
403
- if (isBool(this.value)) {
404
- throw new Exception({
405
- message: `${this.value} is bool`,
406
- code: 1050,
407
- status: "not-is-bool"
408
- });
409
- }
410
- return this;
411
- }
412
- notToBeBasicType() {
413
- if (isBasic(this.value)) {
414
- throw new Exception({
415
- message: `${this.value} is basic type`,
416
- code: 1051,
417
- status: "not-is-basic-type"
418
- });
419
- }
420
- return this;
421
- }
422
- notToBePrimitive() {
423
- if (isPrimitive(this.value)) {
424
- throw new Exception({
425
- message: `${this.value} is primitive type`,
426
- code: 1052,
427
- status: "not-is-primitive"
428
- });
429
- }
430
- return this;
431
- }
432
- notToBeEmpty() {
433
- if (isEmpty(this.value)) {
434
- throw new Exception({
435
- message: `${this.value} is empty`,
436
- code: 1053,
437
- status: "not-is-empty"
438
- });
439
- }
440
- return this;
441
- }
442
- notToBeObject() {
443
- if (isObject(this.value)) {
444
- throw new Exception({
445
- message: `${this.value} is object`,
446
- code: 1054,
447
- status: "not-is-object"
448
- });
449
- }
450
- return this;
451
- }
452
- notToBeSomeObject() {
453
- if (isSomeObject(this.value)) {
454
- throw new Exception({
455
- message: `${this.value} is some object`,
456
- code: 1055,
457
- status: "not-is-some-object"
458
- });
459
- }
460
- return this;
461
- }
462
- notToBeFunction() {
463
- if (isFunction(this.value)) {
464
- throw new Exception({
465
- message: `${this.value} is function`,
466
- code: 1056,
467
- status: "not-is-function"
468
- });
469
- }
470
- return this;
471
- }
472
- notToBeNumeric() {
473
- if (isNumeric(this.value)) {
474
- throw new Exception({
475
- message: `${this.value} is numeric`,
476
- code: 1057,
477
- status: "not-is-numeric"
478
- });
479
- }
480
- return this;
481
- }
482
- notToBeArray() {
483
- if (isArray(this.value)) {
484
- throw new Exception({
485
- message: `${this.value} is array`,
486
- code: 1058,
487
- status: "not-is-array"
488
- });
489
- }
490
- return this;
491
- }
492
- toBeEmptyArray() {
493
- if (isSomeArray(this.value)) {
494
- throw new Exception({
495
- message: `${this.value} is some array`,
496
- code: 1059,
497
- status: "to-be-empty-array"
498
- });
499
- }
500
- return this;
501
- }
502
- notToBeIterable() {
503
- if (isIterable(this.value)) {
504
- throw new Exception({
505
- message: `${this.value} is iterable`,
506
- code: 1060,
507
- status: "not-iterable"
508
- });
509
- }
510
- return this;
511
- }
512
- notToBeSubClassOf(type) {
513
- if (isSubClassOf(this.value, type)) {
514
- throw new Exception({
515
- message: `${this.value} is subclass of ${type}`,
516
- code: 1061,
517
- status: "not-subclassof"
518
- });
519
- }
520
- return this;
521
- }
522
- notToBeInstanceOf(type) {
523
- if (this.value instanceof type) {
524
- throw new Exception({
525
- message: `${this.value} is instance of ${type}`,
526
- code: 1062,
527
- status: "not-instanceof"
528
- });
529
- }
530
- return this;
531
- }
532
- doesNotMatch(pattern, flags) {
533
- const r = new RegExp(pattern, flags);
534
- if (r.test(this.value)) {
535
- throw new Exception({
536
- message: `${this.value} matches ${pattern}`,
537
- code: 1063,
538
- status: "not-match"
539
- });
540
- }
541
- return this;
542
- }
543
- toBeValid(fnValidation) {
544
- if (!isFunction(fnValidation)) {
545
- throw new Exception({
546
- message: `fnValidation is not function`,
547
- code: 1064,
548
- status: "to-be-valid"
549
- });
550
- }
551
- if (!fnValidation(this.value)) {
552
- throw new Exception({
553
- message: `${this.value} is not valid`,
554
- code: 1065,
555
- status: "to-be-valid"
556
- });
557
- }
558
- return this;
559
- }
560
- notToBeValid(fnValidation) {
561
- if (!isFunction(fnValidation)) {
562
- throw new Exception({
563
- message: `fnValidation is not function`,
564
- code: 1066,
565
- status: "not-to-be-valid"
566
- });
567
- }
568
- if (fnValidation(this.value)) {
569
- throw new Exception({
570
- message: `${this.value} is valid`,
571
- code: 1067,
572
- status: "not-to-be-valid"
573
- });
574
- }
575
- return this;
576
- }
577
- toThrow(ex, shape = false, strict = false) {
578
- if (!isFunction(this.value)) {
579
- throw new Exception({
580
- message: `given argument is not a function.`,
581
- code: 1012,
582
- status: "not-func"
583
- });
584
- }
585
- let ok = false;
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;
586
33
  try {
587
- this.value();
588
- ok = true;
34
+ return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
589
35
  } catch (e) {
590
- if (ex !== undefined) {
591
- if (isPrimitive(ex)) {
592
- if (e !== ex) {
593
- throw new Exception({
594
- message: `given function threw incorrect error.`,
595
- code: 1018,
596
- status: "incorrect-throw-error"
597
- });
598
- }
599
- } else if (isFunction(ex)) {
600
- if (!(e instanceof ex)) {
601
- throw new Exception({
602
- message: `given function threw incorrect instance.`,
603
- code: 1019,
604
- status: "incorrect-throw-instance"
605
- });
606
- }
607
- } else if (isObject(ex)) {
608
- if (shape) {
609
- if (!equals(e, ex, strict)) {
610
- throw new Exception({
611
- message: `given function threw incorrect object shape.`,
612
- code: 1020,
613
- status: "incorrect-throw-shape"
36
+ return false;
37
+ }
38
+ }
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;
60
+ }
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) {
885
+ throw new TestException({
886
+ message: "given function threw incorrect error.",
887
+ code: 1018,
888
+ status: "incorrect-throw-error"
614
889
  });
615
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
+ }
616
917
  } else {
617
918
  if (e !== ex) {
618
- throw new Exception({
619
- message: `given function threw incorrect object.`,
620
- code: 1021,
621
- status: "incorrect-throw-object"
919
+ throw new TestException({
920
+ message: "given function threw incorrect value.",
921
+ code: 1022,
922
+ status: "incorrect-throw-value"
622
923
  });
623
924
  }
624
925
  }
625
- } else {
626
- if (e !== ex) {
627
- throw new Exception({
628
- message: `given function threw incorrect value.`,
629
- code: 1022,
630
- status: "incorrect-throw-value"
631
- });
632
- }
633
926
  }
634
927
  }
635
- }
636
- if (ok) {
637
- throw new Exception({
638
- message: `given function ran without throwing any errors.`,
639
- code: 1013,
640
- status: "ran-to-completion"
641
- });
642
- }
643
- return this;
644
- }
645
- async toThrowAsync(ex, shape = false, strict = false) {
646
- if (!isFunction(this.value)) {
647
- throw new Exception({
648
- message: `given argument is not a function.`,
649
- code: 1012,
650
- status: "not-func"
651
- });
652
- }
653
- let ok = false;
654
- try {
655
- await this.value();
656
- ok = true;
657
- } catch (e) {
658
- if (ex !== undefined) {
659
- if (isPrimitive(ex)) {
660
- if (e !== ex) {
661
- throw new Exception({
662
- message: `given function threw incorrect error.`,
663
- code: 1018,
664
- status: "incorrect-throw-error"
665
- });
666
- }
667
- } else if (isFunction(ex)) {
668
- if (!(e instanceof ex)) {
669
- throw new Exception({
670
- message: `given function threw incorrect instance.`,
671
- code: 1019,
672
- status: "incorrect-throw-instance"
673
- });
674
- }
675
- } else if (isObject(ex)) {
676
- if (shape) {
677
- if (!equals(e, ex, strict)) {
678
- throw new Exception({
679
- message: `given function threw incorrect object shape.`,
680
- code: 1020,
681
- status: "incorrect-throw-shape"
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) {
960
+ throw new TestException({
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"
682
972
  });
683
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
+ }
684
992
  } else {
685
- if (e !== ex) {
686
- throw new Exception({
687
- message: `given function threw incorrect object.`,
688
- code: 1021,
689
- status: "incorrect-throw-object"
993
+ if (e === ex) {
994
+ throw new TestException({
995
+ message: "given function threw incorrect value.",
996
+ code: 1022,
997
+ status: "incorrect-throw-value"
690
998
  });
691
999
  }
692
1000
  }
693
- } else {
694
- if (e !== ex) {
695
- throw new Exception({
696
- message: `given function threw incorrect value.`,
697
- code: 1022,
698
- status: "incorrect-throw-value"
699
- });
700
- }
701
1001
  }
702
1002
  }
703
- }
704
- if (ok) {
705
- throw new Exception({
706
- message: `given function ran without throwing any errors.`,
707
- code: 1013,
708
- status: "ran-to-completion"
709
- });
710
- }
711
- return this;
712
- }
713
- notToThrow(ex, shape = false, strict = false) {
714
- if (!isFunction(this.value)) {
715
- throw new Exception({
716
- message: `given argument is not a function.`,
717
- code: 1012,
718
- status: "not-func"
719
- });
720
- }
721
- let ok = true;
722
- let error;
723
- try {
724
- this.value();
725
- ok = false;
726
- } catch (e) {
727
- error = e;
728
- if (ex !== undefined) {
729
- if (isPrimitive(ex)) {
730
- if (e === ex) {
731
- throw new Exception({
732
- message: `given function threw incorrect error.`,
733
- code: 1018,
734
- status: "incorrect-throw-error"
735
- });
736
- }
737
- } else if (isFunction(ex)) {
738
- if (e instanceof ex) {
739
- throw new Exception({
740
- message: `given function threw incorrect instance.`,
741
- code: 1019,
742
- status: "incorrect-throw-instance"
743
- });
744
- }
745
- } else if (isObject(ex)) {
746
- if (shape) {
747
- if (equals(e, ex, strict)) {
748
- throw new Exception({
749
- message: `given function threw incorrect object shape.`,
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
+ }
1098
+ throw new TestException({
1099
+ message: "given function threw incorrect object shape.",
750
1100
  code: 1020,
751
1101
  status: "incorrect-throw-shape"
752
1102
  });
753
- }
754
- } else {
755
- if (e === ex) {
756
- throw new Exception({
757
- message: `given function threw incorrect object.`,
1103
+ case 29:
1104
+ _context.next = 33;
1105
+ break;
1106
+ case 31:
1107
+ if (!(_context.t0 !== ex)) {
1108
+ _context.next = 33;
1109
+ break;
1110
+ }
1111
+ throw new TestException({
1112
+ message: "given function threw incorrect object.",
758
1113
  code: 1021,
759
1114
  status: "incorrect-throw-object"
760
1115
  });
761
- }
762
- }
763
- } else {
764
- if (e === ex) {
765
- throw new Exception({
766
- message: `given function threw incorrect value.`,
767
- code: 1022,
768
- status: "incorrect-throw-value"
769
- });
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();
770
1144
  }
771
- }
1145
+ }, _callee, this, [[6, 12]]);
1146
+ }));
1147
+ function toThrowAsync(_x) {
1148
+ return _toThrowAsync.apply(this, arguments);
772
1149
  }
773
- }
774
- if (ok) {
775
- throw new Exception({
776
- message: `given function threw an error.`,
777
- code: 1014,
778
- status: "ran-to-error",
779
- innerException: error
780
- });
781
- }
782
- return this;
783
- }
784
- async notToThrowAsync(ex, shape = false, strict = false) {
785
- if (!isFunction(this.value)) {
786
- throw new Exception({
787
- message: `given argument is not a function.`,
788
- code: 1012,
789
- status: "not-func"
790
- });
791
- }
792
- let ok = true;
793
- let error;
794
- try {
795
- await this.value();
796
- ok = false;
797
- } catch (e) {
798
- error = e;
799
- if (ex !== undefined) {
800
- if (isPrimitive(ex)) {
801
- if (e === ex) {
802
- throw new Exception({
803
- message: `given function threw incorrect error.`,
804
- code: 1018,
805
- status: "incorrect-throw-error"
806
- });
807
- }
808
- } else if (isFunction(ex)) {
809
- if (e instanceof ex) {
810
- throw new Exception({
811
- message: `given function threw incorrect instance.`,
812
- code: 1019,
813
- status: "incorrect-throw-instance"
814
- });
815
- }
816
- } else if (isObject(ex)) {
817
- if (shape) {
818
- if (equals(e, ex, strict)) {
819
- throw new Exception({
820
- message: `given function threw incorrect object shape.`,
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
+ }
1239
+ throw new TestException({
1240
+ message: "given function threw incorrect object shape.",
821
1241
  code: 1020,
822
1242
  status: "incorrect-throw-shape"
823
1243
  });
824
- }
825
- } else {
826
- if (e === ex) {
827
- throw new Exception({
828
- message: `given function threw incorrect object.`,
1244
+ case 30:
1245
+ _context2.next = 34;
1246
+ break;
1247
+ case 32:
1248
+ if (!(_context2.t0 === ex)) {
1249
+ _context2.next = 34;
1250
+ break;
1251
+ }
1252
+ throw new TestException({
1253
+ message: "given function threw incorrect object.",
829
1254
  code: 1021,
830
1255
  status: "incorrect-throw-object"
831
1256
  });
832
- }
833
- }
834
- } else {
835
- if (e === ex) {
836
- throw new Exception({
837
- message: `given function threw incorrect value.`,
838
- code: 1022,
839
- status: "incorrect-throw-value"
840
- });
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();
841
1286
  }
842
- }
1287
+ }, _callee2, this, [[6, 12]]);
1288
+ }));
1289
+ function notToThrowAsync(_x2) {
1290
+ return _notToThrowAsync.apply(this, arguments);
843
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;
844
1355
  }
845
- if (ok) {
846
- throw new Exception({
847
- message: `given function threw an error.`,
848
- code: 1014,
849
- status: "ran-to-error",
850
- innerException: error
851
- });
852
- }
853
- return this;
854
- }
855
- toBeTruthy() {
856
- if (this.value) {} else {
857
- throw new Exception({
858
- message: `${this.value} is not truthy`,
859
- code: 1015,
860
- status: "not-truthy"
861
- });
862
- }
863
- return this;
864
- }
865
- toBeTrue() {
866
- return this.toBeTruthy();
867
- }
868
- toBeFalsy() {
869
- if (!this.value) {} else {
870
- throw new Exception({
871
- message: `${this.value} is not falsy`,
872
- code: 1016,
873
- status: "not-falsy"
874
- });
875
- }
876
- return this;
877
- }
878
- toBeFalse() {
879
- return this.toBeFalsy();
880
- }
881
- toBeNaN() {
882
- if (isNaN(this.value)) {} else {
883
- throw new Exception({
884
- message: `${this.value} is not NaN`,
885
- code: 1017,
886
- status: "not-nan"
887
- });
888
- }
889
- return this;
890
- }
891
- notToBeNaN() {
892
- if (!isNaN(this.value)) {} else {
893
- throw new Exception({
894
- message: `${this.value} is NaN`,
895
- code: 1023,
896
- status: "is-nan"
897
- });
898
- }
899
- return this;
900
- }
901
- }
902
- const expect = x => new Expect(x);
903
- class Test {
904
- constructor(name, fn) {
1356
+ }]);
1357
+ }();
1358
+ var Test = exports.Test = /*#__PURE__*/function () {
1359
+ function Test(name, fn) {
1360
+ _classCallCheck(this, Test);
905
1361
  this.name = name;
906
1362
  this.fn = fn;
907
1363
  }
908
- run() {
909
- return new Promise(res => {
910
- const start = new Date();
911
- if (isFunction(this.fn)) {
912
- try {
913
- const _result = this.fn(expect);
914
- if (_result && isFunction(_result.then)) {
915
- _result.then(result => {
916
- res({
917
- success: true,
918
- test: this.name,
919
- result,
920
- time: new Date() - start
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
+ });
921
1399
  });
922
- }).catch(ex => {
1400
+ } else {
923
1401
  res({
924
- success: false,
925
- test: this.name,
1402
+ success: true,
1403
+ test: _this2.name,
926
1404
  time: new Date() - start,
927
- err: new Exception({
928
- message: `test '${this.name}' failed.`,
929
- code: 501,
930
- status: "failed",
931
- innerException: ex
932
- })
1405
+ result: _result,
1406
+ expected: _expect.expected
933
1407
  });
934
- });
935
- } else {
1408
+ }
1409
+ } catch (ex) {
936
1410
  res({
937
- success: true,
938
- test: this.name,
1411
+ success: false,
1412
+ test: _this2.name,
939
1413
  time: new Date() - start,
940
- result: _result
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
+ })
941
1421
  });
942
1422
  }
943
- } catch (ex) {
1423
+ } else {
944
1424
  res({
945
1425
  success: false,
946
- test: this.name,
1426
+ test: _this2.name,
947
1427
  time: new Date() - start,
948
- err: new Exception({
949
- message: `test '${this.name}' failed.`,
950
- code: 501,
951
- status: "failed",
952
- innerException: ex
1428
+ err: new TestException({
1429
+ message: "test '".concat(_this2.name, "' does not have a function to be called."),
1430
+ code: 500,
1431
+ status: "no-func"
953
1432
  })
954
1433
  });
955
1434
  }
956
- } else {
957
- res({
958
- success: false,
959
- test: this.name,
960
- time: new Date() - start,
961
- err: new Exception({
962
- message: `test '${this.name}' does not have a function to be called.`,
963
- code: 500,
964
- status: "no-func"
965
- })
966
- });
967
- }
968
- });
969
- }
970
- }
971
- const reset = "\x1b[0m";
972
- const bright = "\x1b[1m";
973
- const dim = "\x1b[2m";
974
- const underscore = "\x1b[4m";
975
- const blink = "\x1b[5m";
976
- const reverse = "\x1b[7m";
977
- const hidden = "\x1b[8m";
978
- const fgBlack = "\x1b[30m";
979
- const fgRed = "\x1b[31m";
980
- const fgGreen = "\x1b[32m";
981
- const fgYellow = "\x1b[33m";
982
- const fgBlue = "\x1b[34m";
983
- const fgMagenta = "\x1b[35m";
984
- const fgCyan = "\x1b[36m";
985
- const fgWhite = "\x1b[37m";
986
- const fgGray = "\x1b[90m";
987
- const bgBlack = "\x1b[40m";
988
- const bgRed = "\x1b[41m";
989
- const bgGreen = "\x1b[42m";
990
- const bgYellow = "\x1b[43m";
991
- const bgBlue = "\x1b[44m";
992
- const bgMagenta = "\x1b[45m";
993
- const bgCyan = "\x1b[46m";
994
- const bgWhite = "\x1b[47m";
995
- const bgGray = "\x1b[100m";
996
- class TestRunner {
997
- 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);
998
1467
  this._passed = 0;
999
1468
  this._failed = 0;
1469
+ this._unknown = 0;
1000
1470
  this._results = [];
1001
1471
  this._errors = [];
1002
1472
  }
1003
- async _runSingle(test, onProgress, i) {
1004
- if (isFunction(onProgress)) {
1005
- try {
1006
- onProgress(i, test);
1007
- } catch (ex) {
1008
- this._errors.push({
1009
- index: i,
1010
- test: test.name,
1011
- err: new Exception({
1012
- message: `onProgress failed for test '${test.name} at index ${i}'.`,
1013
- code: 1500,
1014
- status: "progress-failed",
1015
- innerException: ex
1016
- })
1017
- });
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
+ }
1500
+ }
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);
1018
1521
  }
1019
- }
1020
- const tr = await test.run();
1021
- this._results.push(tr);
1022
- if (tr.success) {
1023
- this._passed++;
1024
- } else {
1025
- this._failed++;
1026
- }
1027
- }
1028
- get result() {
1029
- return {
1030
- passed: this._passed,
1031
- failed: this._failed,
1032
- results: this._results,
1033
- errors: this._errors
1034
- };
1035
- }
1036
- run(tests, onProgress) {
1037
- this._passed = 0;
1038
- this._failed = 0;
1039
- this._results = [];
1040
- this._errors = [];
1041
- return new Promise(res => {
1042
- if (tests) {
1043
- if (tests instanceof Test) {
1044
- tests = [tests];
1045
- }
1046
- if (isArray(tests)) {
1047
- const _tests = tests.map(test => {
1048
- let _test = test;
1049
- if (isArray(test)) {
1050
- if (test.length == 2) {
1051
- _test = new Test(test[0], test[1]);
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
+ }
1052
1554
  }
1053
- }
1054
- return _test;
1055
- }).filter(test => test instanceof Test).map((test, i) => this._runSingle(test, onProgress, i));
1056
- Promise.all(_tests).then(_ => res(this.result)).catch(ex => {
1057
- this._errors.push({
1058
- err: new Exception({
1059
- message: `not all tests succeeded. check errors.`,
1060
- code: 1503,
1061
- status: "partial-finished",
1062
- innerException: ex
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({
1576
+ err: new TestException({
1577
+ message: "invalid tests. expected array or a single test.",
1578
+ code: 1502,
1579
+ status: "invalid-tests"
1063
1580
  })
1064
1581
  });
1065
- res(this.result);
1066
- });
1582
+ res(_this3.result);
1583
+ }
1067
1584
  } else {
1068
- this._errors.push({
1069
- err: new Exception({
1070
- message: `invalid tests. expected array or a single test.`,
1071
- code: 1502,
1072
- status: "invalid-tests"
1585
+ _this3._errors.push({
1586
+ err: new TestException({
1587
+ message: "no tests given to be ran.",
1588
+ code: 1501,
1589
+ status: "no-tests"
1073
1590
  })
1074
1591
  });
1075
- res(this.result);
1592
+ res(_this3.result);
1076
1593
  }
1077
- } else {
1078
- this._errors.push({
1079
- err: new Exception({
1080
- message: `no tests given to be ran.`,
1081
- code: 1501,
1082
- status: "no-tests"
1083
- })
1084
- });
1085
- res(this.result);
1086
- }
1087
- });
1088
- }
1089
- _getTime(time) {
1090
- return `${time / 1000} sec`;
1091
- }
1092
- report(detailed) {
1093
- let time = 0;
1094
- console.log("Finished.\n");
1095
- for (let i = 0; i < this._results.length; i++) {
1096
- const result = this._results[i];
1097
- const t = `(${this._getTime(result.time)})`;
1098
- if (detailed) {
1099
- let message = "\n" + (i + 1) + ". ";
1100
- if (result.success) {
1101
- message += `${fgWhite}${result.test}: ${fgGreen}passed${reset} ${t}`;
1102
- } else {
1103
- message += `${bright}${fgWhite}${result.test}: ${fgRed}failed${reset} ${t}`;
1104
- message += "\n";
1105
- let err = result.err.toString().split("\n");
1106
- err = err.map((msg, i) => `\t${i == err.length - 1 ? `${fgYellow}` : `${fgGray}error ${result.err.code}: `}${msg}${reset}`).join("\n");
1107
- message += `${fgGray}${err} ${reset}`;
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);
1108
1630
  }
1109
- console.log(message);
1631
+ time += testResult.time;
1632
+ };
1633
+ for (var i = 0; i < this._results.length; i++) {
1634
+ _loop();
1110
1635
  }
1111
- time += result.time;
1112
- }
1113
- if (detailed && this._errors.length) {
1114
- console.log("Errors:");
1115
- for (let error of this._errors) {
1116
- if (error.index !== undefined) {
1117
- console.log(`${error.index}. ${error.test}: ${error.err.innerException.toString()}`);
1118
- } else {
1119
- console.log(`${error.err.toString()}`);
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();
1120
1653
  }
1121
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
+ }
1122
1682
  }
1123
- const text = (detailed ? "\n" : "") + `${bright}Number of tests: ${reset}${this._passed + this._failed}` + "\n" + `${bright}Total Time: ${reset}${time / 1000} sec` + "\n\n" + (this._passed > 0 ? `${fgGreen} ${this._passed} test(s) passed${reset}` : `0 tests passed${reset}`) + ", " + (this._failed > 0 ? `${fgRed} ${this._failed} test(s) failed${reset}` : `0 tests failed${reset}`) + "\n";
1124
- console.log(text);
1125
- }
1126
- log(filename) {
1127
- const content = JSON.stringify({
1128
- results: this._results,
1129
- errors: this._errors
1130
- }, null, "\t");
1131
- if (filename == null) {
1132
- const d = new Date();
1133
- const year = d.getFullYear().toString().padStart(4, "0");
1134
- const month = (d.getMonth() + 1).toString().padStart(2, "0");
1135
- const day = d.getDate().toString().padStart(2, "0");
1136
- const hours = d.getHours().toString().padStart(2, "0");
1137
- const minutes = d.getMinutes().toString().padStart(2, "0");
1138
- const seconds = d.getSeconds().toString().padStart(2, "0");
1139
- filename = `test-${year}-${month}-${day}-${hours}${minutes}${seconds}.json`;
1140
- }
1141
- const filepath = path.join(process.cwd(), filename);
1142
- try {
1143
- fs.writeFileSync(filepath, content);
1144
- console.log(`tests outcome wrote in ${filename}.`);
1145
- } catch (ex) {
1146
- console.log("writing tests outcome failed.\n" + ex);
1147
- }
1148
- }
1149
- static start(tests) {
1150
- const tr = new TestRunner();
1151
- tr.run(tests).then(result => tr.report(result.failed > 0));
1152
- }
1153
- }
1154
- export default TestRunner;
1155
- export { Test, Expect, expect };
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;