@dereekb/util 13.0.0 → 13.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test/index.cjs.js CHANGED
@@ -1,38 +1,251 @@
1
1
  'use strict';
2
2
 
3
3
  var util = require('@dereekb/util');
4
+ var makeError = require('make-error');
4
5
 
6
+ function _assert_this_initialized$4(self) {
7
+ if (self === void 0) {
8
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
9
+ }
10
+ return self;
11
+ }
12
+ function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
13
+ try {
14
+ var info = gen[key](arg);
15
+ var value = info.value;
16
+ } catch (error) {
17
+ reject(error);
18
+ return;
19
+ }
20
+ if (info.done) {
21
+ resolve(value);
22
+ } else {
23
+ Promise.resolve(value).then(_next, _throw);
24
+ }
25
+ }
26
+ function _async_to_generator$2(fn) {
27
+ return function() {
28
+ var self = this, args = arguments;
29
+ return new Promise(function(resolve, reject) {
30
+ var gen = fn.apply(self, args);
31
+ function _next(value) {
32
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
33
+ }
34
+ function _throw(err) {
35
+ asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
36
+ }
37
+ _next(undefined);
38
+ });
39
+ };
40
+ }
41
+ function _call_super$4(_this, derived, args) {
42
+ derived = _get_prototype_of$4(derived);
43
+ return _possible_constructor_return$4(_this, _is_native_reflect_construct$4() ? Reflect.construct(derived, [], _get_prototype_of$4(_this).constructor) : derived.apply(_this, args));
44
+ }
45
+ function _class_call_check$4(instance, Constructor) {
46
+ if (!(instance instanceof Constructor)) {
47
+ throw new TypeError("Cannot call a class as a function");
48
+ }
49
+ }
50
+ function _defineProperties(target, props) {
51
+ for(var i = 0; i < props.length; i++){
52
+ var descriptor = props[i];
53
+ descriptor.enumerable = descriptor.enumerable || false;
54
+ descriptor.configurable = true;
55
+ if ("value" in descriptor) descriptor.writable = true;
56
+ Object.defineProperty(target, descriptor.key, descriptor);
57
+ }
58
+ }
59
+ function _create_class(Constructor, protoProps, staticProps) {
60
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
61
+ return Constructor;
62
+ }
63
+ function _define_property$2(obj, key, value) {
64
+ if (key in obj) {
65
+ Object.defineProperty(obj, key, {
66
+ value: value,
67
+ enumerable: true,
68
+ configurable: true,
69
+ writable: true
70
+ });
71
+ } else {
72
+ obj[key] = value;
73
+ }
74
+ return obj;
75
+ }
76
+ function _get_prototype_of$4(o) {
77
+ _get_prototype_of$4 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
78
+ return o.__proto__ || Object.getPrototypeOf(o);
79
+ };
80
+ return _get_prototype_of$4(o);
81
+ }
82
+ function _inherits$4(subClass, superClass) {
83
+ if (typeof superClass !== "function" && superClass !== null) {
84
+ throw new TypeError("Super expression must either be null or a function");
85
+ }
86
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
87
+ constructor: {
88
+ value: subClass,
89
+ writable: true,
90
+ configurable: true
91
+ }
92
+ });
93
+ if (superClass) _set_prototype_of$4(subClass, superClass);
94
+ }
95
+ function _possible_constructor_return$4(self, call) {
96
+ if (call && (_type_of$4(call) === "object" || typeof call === "function")) {
97
+ return call;
98
+ }
99
+ return _assert_this_initialized$4(self);
100
+ }
101
+ function _set_prototype_of$4(o, p) {
102
+ _set_prototype_of$4 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
103
+ o.__proto__ = p;
104
+ return o;
105
+ };
106
+ return _set_prototype_of$4(o, p);
107
+ }
108
+ function _type_of$4(obj) {
109
+ "@swc/helpers - typeof";
110
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
111
+ }
112
+ function _is_native_reflect_construct$4() {
113
+ try {
114
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
115
+ } catch (_) {}
116
+ return (_is_native_reflect_construct$4 = function() {
117
+ return !!result;
118
+ })();
119
+ }
120
+ function _ts_generator$2(thisArg, body) {
121
+ var f, y, t, _ = {
122
+ label: 0,
123
+ sent: function() {
124
+ if (t[0] & 1) throw t[1];
125
+ return t[1];
126
+ },
127
+ trys: [],
128
+ ops: []
129
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
130
+ return d(g, "next", {
131
+ value: verb(0)
132
+ }), d(g, "throw", {
133
+ value: verb(1)
134
+ }), d(g, "return", {
135
+ value: verb(2)
136
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
137
+ value: function() {
138
+ return this;
139
+ }
140
+ }), g;
141
+ function verb(n) {
142
+ return function(v) {
143
+ return step([
144
+ n,
145
+ v
146
+ ]);
147
+ };
148
+ }
149
+ function step(op) {
150
+ if (f) throw new TypeError("Generator is already executing.");
151
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
152
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
153
+ if (y = 0, t) op = [
154
+ op[0] & 2,
155
+ t.value
156
+ ];
157
+ switch(op[0]){
158
+ case 0:
159
+ case 1:
160
+ t = op;
161
+ break;
162
+ case 4:
163
+ _.label++;
164
+ return {
165
+ value: op[1],
166
+ done: false
167
+ };
168
+ case 5:
169
+ _.label++;
170
+ y = op[1];
171
+ op = [
172
+ 0
173
+ ];
174
+ continue;
175
+ case 7:
176
+ op = _.ops.pop();
177
+ _.trys.pop();
178
+ continue;
179
+ default:
180
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
181
+ _ = 0;
182
+ continue;
183
+ }
184
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
185
+ _.label = op[1];
186
+ break;
187
+ }
188
+ if (op[0] === 6 && _.label < t[1]) {
189
+ _.label = t[1];
190
+ t = op;
191
+ break;
192
+ }
193
+ if (t && _.label < t[2]) {
194
+ _.label = t[2];
195
+ _.ops.push(op);
196
+ break;
197
+ }
198
+ if (t[2]) _.ops.pop();
199
+ _.trys.pop();
200
+ continue;
201
+ }
202
+ op = body.call(thisArg, _);
203
+ } catch (e) {
204
+ op = [
205
+ 6,
206
+ e
207
+ ];
208
+ y = 0;
209
+ } finally{
210
+ f = t = 0;
211
+ }
212
+ if (op[0] & 5) throw op[1];
213
+ return {
214
+ value: op[0] ? op[1] : void 0,
215
+ done: true
216
+ };
217
+ }
218
+ }
5
219
  /**
6
220
  * Passes the error to the TestDoneCallback.
7
221
  * @param done
8
222
  * @param e
9
- */
10
- function failWithTestDoneCallback(done, e = new Error('failed test')) {
11
- if (done.fail != null) {
12
- done.fail(e);
13
- } else {
14
- done(e);
15
- }
223
+ */ function failWithTestDoneCallback(done) {
224
+ var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : new Error('failed test');
225
+ if (done.fail != null) {
226
+ done.fail(e);
227
+ } else {
228
+ done(e);
229
+ }
16
230
  }
17
231
  /**
18
232
  * Creates a new TestDoneCallbackRef.
19
233
  *
20
234
  * Used to create a promise reference that can be used to assert that a test function was called.
21
- */
22
- function testDoneCallbackRef() {
23
- const _promise = util.promiseReference();
24
- const done = e => {
25
- if (e) {
26
- _promise.reject(e);
27
- } else {
28
- _promise.resolve();
29
- }
30
- };
31
- done.fail = done;
32
- return {
33
- _promise,
34
- done
35
- };
235
+ */ function testDoneCallbackRef() {
236
+ var _promise = util.promiseReference();
237
+ var done = function done(e) {
238
+ if (e) {
239
+ _promise.reject(e);
240
+ } else {
241
+ _promise.resolve();
242
+ }
243
+ };
244
+ done.fail = done;
245
+ return {
246
+ _promise: _promise,
247
+ done: done
248
+ };
36
249
  }
37
250
  /**
38
251
  * Wraps a callback-based test (using done) for Vitest compatibility.
@@ -53,403 +266,822 @@ function testDoneCallbackRef() {
53
266
  * // async test code
54
267
  * done();
55
268
  * }));
56
- */
57
- function callbackTest(testFn) {
58
- return async () => {
59
- const done = testDoneCallbackRef();
60
- await testFn(done.done);
61
- return done._promise.promise;
62
- };
269
+ */ function callbackTest(testFn) {
270
+ return function() {
271
+ return _async_to_generator$2(function() {
272
+ var done;
273
+ return _ts_generator$2(this, function(_state) {
274
+ switch(_state.label){
275
+ case 0:
276
+ done = testDoneCallbackRef();
277
+ return [
278
+ 4,
279
+ testFn(done.done)
280
+ ];
281
+ case 1:
282
+ _state.sent();
283
+ return [
284
+ 2,
285
+ done._promise.promise
286
+ ];
287
+ }
288
+ });
289
+ })();
290
+ };
63
291
  }
64
292
  /**
65
293
  * Abstract TestContextFixture instance.
66
- */
67
- class AbstractTestContextFixture {
68
- constructor() {
69
- this._instance = void 0;
70
- }
71
- get instance() {
72
- return this._instance;
73
- }
74
- setInstance(instance) {
75
- if (this._instance != null) {
76
- throw new Error(`The testing fixture is locked. Don't call setInstance() directly.`);
77
- }
78
- this._instance = instance;
79
- return () => {
80
- delete this._instance;
81
- };
82
- }
83
- }
294
+ */ var AbstractTestContextFixture = /*#__PURE__*/ function() {
295
+ function AbstractTestContextFixture() {
296
+ _class_call_check$4(this, AbstractTestContextFixture);
297
+ _define_property$2(this, "_instance", void 0);
298
+ }
299
+ _create_class(AbstractTestContextFixture, [
300
+ {
301
+ key: "instance",
302
+ get: function get() {
303
+ return this._instance;
304
+ }
305
+ },
306
+ {
307
+ key: "setInstance",
308
+ value: function setInstance(instance) {
309
+ var _this = this;
310
+ if (this._instance != null) {
311
+ throw new Error("The testing fixture is locked. Don't call setInstance() directly.");
312
+ }
313
+ this._instance = instance;
314
+ return function() {
315
+ delete _this._instance;
316
+ };
317
+ }
318
+ }
319
+ ]);
320
+ return AbstractTestContextFixture;
321
+ }();
84
322
  /**
85
323
  * Abstract TestContextFixture instance with a parent.
86
- */
87
- class AbstractChildTestContextFixture extends AbstractTestContextFixture {
88
- constructor(parent) {
89
- super();
90
- this.parent = void 0;
91
- this.parent = parent;
92
- }
93
- }
324
+ */ var AbstractChildTestContextFixture = /*#__PURE__*/ function(AbstractTestContextFixture) {
325
+ _inherits$4(AbstractChildTestContextFixture, AbstractTestContextFixture);
326
+ function AbstractChildTestContextFixture(parent) {
327
+ _class_call_check$4(this, AbstractChildTestContextFixture);
328
+ var _this;
329
+ _this = _call_super$4(this, AbstractChildTestContextFixture), _define_property$2(_this, "parent", void 0);
330
+ _this.parent = parent;
331
+ return _this;
332
+ }
333
+ return AbstractChildTestContextFixture;
334
+ }(AbstractTestContextFixture);
94
335
  /**
95
336
  * Creates a TestContextBuilderFunction given the input builder.
96
337
  *
97
338
  * @param builder
98
339
  * @returns
99
- */
100
- function testContextBuilder(builder) {
101
- return inputConfig => {
102
- const config = builder.buildConfig(inputConfig);
103
- return buildTests => {
104
- const fixture = builder.buildFixture(config);
105
- // add before each
106
- if (builder.beforeEach != null) {
107
- beforeEach(builder.beforeEach);
108
- }
109
- // add tests
110
- useTestContextFixture({
111
- fixture,
112
- /**
113
- * Build tests by passing the fixture to the testing functions.
114
- *
115
- * This will inject all tests and sub lifecycle items.
116
- */
117
- buildTests,
118
- initInstance: () => builder.setupInstance(config),
119
- destroyInstance: instance => builder.teardownInstance(instance, config)
120
- });
121
- // add after each
122
- if (builder.afterEach != null) {
123
- afterEach(builder.afterEach);
124
- }
340
+ */ function testContextBuilder(builder) {
341
+ return function(inputConfig) {
342
+ var config = builder.buildConfig(inputConfig);
343
+ return function(buildTests) {
344
+ var fixture = builder.buildFixture(config);
345
+ // add before each
346
+ if (builder.beforeEach != null) {
347
+ beforeEach(builder.beforeEach);
348
+ }
349
+ // add tests
350
+ useTestContextFixture({
351
+ fixture: fixture,
352
+ /**
353
+ * Build tests by passing the fixture to the testing functions.
354
+ *
355
+ * This will inject all tests and sub lifecycle items.
356
+ */ buildTests: buildTests,
357
+ initInstance: function initInstance() {
358
+ return builder.setupInstance(config);
359
+ },
360
+ destroyInstance: function destroyInstance(instance) {
361
+ return builder.teardownInstance(instance, config);
362
+ }
363
+ });
364
+ // add after each
365
+ if (builder.afterEach != null) {
366
+ afterEach(builder.afterEach);
367
+ }
368
+ };
125
369
  };
126
- };
127
370
  }
128
371
  /**
129
372
  * Creates a test context and configurations that will initialize an instance
130
- */
131
- function useTestContextFixture(config) {
132
- const {
133
- buildTests,
134
- fixture,
135
- initInstance,
136
- destroyInstance
137
- } = config;
138
- let clearInstance;
139
- let instance;
140
- // Create an instance
141
- beforeEach(async () => {
373
+ */ function useTestContextFixture(config) {
374
+ var buildTests = config.buildTests, fixture = config.fixture, initInstance = config.initInstance, destroyInstance = config.destroyInstance;
375
+ var clearInstance;
376
+ var instance;
377
+ // Create an instance
378
+ beforeEach(function() {
379
+ return _async_to_generator$2(function() {
380
+ var e;
381
+ return _ts_generator$2(this, function(_state) {
382
+ switch(_state.label){
383
+ case 0:
384
+ _state.trys.push([
385
+ 0,
386
+ 2,
387
+ ,
388
+ 3
389
+ ]);
390
+ return [
391
+ 4,
392
+ initInstance()
393
+ ];
394
+ case 1:
395
+ instance = _state.sent();
396
+ clearInstance = fixture.setInstance(instance);
397
+ return [
398
+ 3,
399
+ 3
400
+ ];
401
+ case 2:
402
+ e = _state.sent();
403
+ console.error('Failed building a test instance due to an error in buildInstance(). Error: ', e);
404
+ if (clearInstance) {
405
+ clearInstance();
406
+ }
407
+ throw e;
408
+ case 3:
409
+ return [
410
+ 2
411
+ ];
412
+ }
413
+ });
414
+ })();
415
+ });
416
+ // Declare tests
417
+ buildTests(fixture);
418
+ // Cleanup
419
+ afterEach(function() {
420
+ return _async_to_generator$2(function() {
421
+ var e;
422
+ return _ts_generator$2(this, function(_state) {
423
+ switch(_state.label){
424
+ case 0:
425
+ if (clearInstance) {
426
+ clearInstance();
427
+ }
428
+ if (fixture.instance != null) {
429
+ console.warn('Expected instance to be set on fixture for cleanup but was set to something else.');
430
+ }
431
+ if (!destroyInstance) return [
432
+ 3,
433
+ 4
434
+ ];
435
+ _state.label = 1;
436
+ case 1:
437
+ _state.trys.push([
438
+ 1,
439
+ 3,
440
+ ,
441
+ 4
442
+ ]);
443
+ return [
444
+ 4,
445
+ destroyInstance(instance)
446
+ ];
447
+ case 2:
448
+ _state.sent();
449
+ instance = undefined;
450
+ return [
451
+ 3,
452
+ 4
453
+ ];
454
+ case 3:
455
+ e = _state.sent();
456
+ console.error('Failed due to error in destroyInstance()');
457
+ throw e;
458
+ case 4:
459
+ return [
460
+ 2
461
+ ];
462
+ }
463
+ });
464
+ })();
465
+ });
466
+ }
467
+
468
+ function _assert_this_initialized$3(self) {
469
+ if (self === void 0) {
470
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
471
+ }
472
+ return self;
473
+ }
474
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
142
475
  try {
143
- instance = await initInstance();
144
- clearInstance = fixture.setInstance(instance);
145
- } catch (e) {
146
- console.error('Failed building a test instance due to an error in buildInstance(). Error: ', e);
147
- if (clearInstance) {
148
- clearInstance();
149
- }
150
- throw e;
151
- }
152
- });
153
- // Declare tests
154
- buildTests(fixture);
155
- // Cleanup
156
- afterEach(async () => {
157
- if (clearInstance) {
158
- clearInstance();
159
- }
160
- if (fixture.instance != null) {
161
- console.warn('Expected instance to be set on fixture for cleanup but was set to something else.');
162
- }
163
- if (destroyInstance) {
164
- try {
165
- await destroyInstance(instance);
166
- instance = undefined;
167
- } catch (e) {
168
- console.error('Failed due to error in destroyInstance()');
169
- throw e;
170
- }
476
+ var info = gen[key](arg);
477
+ var value = info.value;
478
+ } catch (error) {
479
+ reject(error);
480
+ return;
481
+ }
482
+ if (info.done) {
483
+ resolve(value);
484
+ } else {
485
+ Promise.resolve(value).then(_next, _throw);
171
486
  }
172
- });
173
487
  }
174
-
175
- class AbstractWrappedFixture {
176
- constructor(fixture) {
177
- this.fixture = void 0;
178
- this.fixture = fixture;
179
- }
488
+ function _async_to_generator$1(fn) {
489
+ return function() {
490
+ var self = this, args = arguments;
491
+ return new Promise(function(resolve, reject) {
492
+ var gen = fn.apply(self, args);
493
+ function _next(value) {
494
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
495
+ }
496
+ function _throw(err) {
497
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
498
+ }
499
+ _next(undefined);
500
+ });
501
+ };
502
+ }
503
+ function _call_super$3(_this, derived, args) {
504
+ derived = _get_prototype_of$3(derived);
505
+ return _possible_constructor_return$3(_this, _is_native_reflect_construct$3() ? Reflect.construct(derived, [], _get_prototype_of$3(_this).constructor) : derived.apply(_this, args));
506
+ }
507
+ function _class_call_check$3(instance, Constructor) {
508
+ if (!(instance instanceof Constructor)) {
509
+ throw new TypeError("Cannot call a class as a function");
510
+ }
180
511
  }
181
- class AbstractWrappedFixtureWithInstance extends AbstractTestContextFixture {
182
- constructor(parent) {
183
- super();
184
- this.parent = void 0;
185
- this.parent = parent;
186
- }
512
+ function _define_property$1(obj, key, value) {
513
+ if (key in obj) {
514
+ Object.defineProperty(obj, key, {
515
+ value: value,
516
+ enumerable: true,
517
+ configurable: true,
518
+ writable: true
519
+ });
520
+ } else {
521
+ obj[key] = value;
522
+ }
523
+ return obj;
524
+ }
525
+ function _get_prototype_of$3(o) {
526
+ _get_prototype_of$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
527
+ return o.__proto__ || Object.getPrototypeOf(o);
528
+ };
529
+ return _get_prototype_of$3(o);
187
530
  }
531
+ function _inherits$3(subClass, superClass) {
532
+ if (typeof superClass !== "function" && superClass !== null) {
533
+ throw new TypeError("Super expression must either be null or a function");
534
+ }
535
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
536
+ constructor: {
537
+ value: subClass,
538
+ writable: true,
539
+ configurable: true
540
+ }
541
+ });
542
+ if (superClass) _set_prototype_of$3(subClass, superClass);
543
+ }
544
+ function _possible_constructor_return$3(self, call) {
545
+ if (call && (_type_of$3(call) === "object" || typeof call === "function")) {
546
+ return call;
547
+ }
548
+ return _assert_this_initialized$3(self);
549
+ }
550
+ function _set_prototype_of$3(o, p) {
551
+ _set_prototype_of$3 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
552
+ o.__proto__ = p;
553
+ return o;
554
+ };
555
+ return _set_prototype_of$3(o, p);
556
+ }
557
+ function _type_of$3(obj) {
558
+ "@swc/helpers - typeof";
559
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
560
+ }
561
+ function _is_native_reflect_construct$3() {
562
+ try {
563
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
564
+ } catch (_) {}
565
+ return (_is_native_reflect_construct$3 = function() {
566
+ return !!result;
567
+ })();
568
+ }
569
+ function _ts_generator$1(thisArg, body) {
570
+ var f, y, t, _ = {
571
+ label: 0,
572
+ sent: function() {
573
+ if (t[0] & 1) throw t[1];
574
+ return t[1];
575
+ },
576
+ trys: [],
577
+ ops: []
578
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
579
+ return d(g, "next", {
580
+ value: verb(0)
581
+ }), d(g, "throw", {
582
+ value: verb(1)
583
+ }), d(g, "return", {
584
+ value: verb(2)
585
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
586
+ value: function() {
587
+ return this;
588
+ }
589
+ }), g;
590
+ function verb(n) {
591
+ return function(v) {
592
+ return step([
593
+ n,
594
+ v
595
+ ]);
596
+ };
597
+ }
598
+ function step(op) {
599
+ if (f) throw new TypeError("Generator is already executing.");
600
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
601
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
602
+ if (y = 0, t) op = [
603
+ op[0] & 2,
604
+ t.value
605
+ ];
606
+ switch(op[0]){
607
+ case 0:
608
+ case 1:
609
+ t = op;
610
+ break;
611
+ case 4:
612
+ _.label++;
613
+ return {
614
+ value: op[1],
615
+ done: false
616
+ };
617
+ case 5:
618
+ _.label++;
619
+ y = op[1];
620
+ op = [
621
+ 0
622
+ ];
623
+ continue;
624
+ case 7:
625
+ op = _.ops.pop();
626
+ _.trys.pop();
627
+ continue;
628
+ default:
629
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
630
+ _ = 0;
631
+ continue;
632
+ }
633
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
634
+ _.label = op[1];
635
+ break;
636
+ }
637
+ if (op[0] === 6 && _.label < t[1]) {
638
+ _.label = t[1];
639
+ t = op;
640
+ break;
641
+ }
642
+ if (t && _.label < t[2]) {
643
+ _.label = t[2];
644
+ _.ops.push(op);
645
+ break;
646
+ }
647
+ if (t[2]) _.ops.pop();
648
+ _.trys.pop();
649
+ continue;
650
+ }
651
+ op = body.call(thisArg, _);
652
+ } catch (e) {
653
+ op = [
654
+ 6,
655
+ e
656
+ ];
657
+ y = 0;
658
+ } finally{
659
+ f = t = 0;
660
+ }
661
+ if (op[0] & 5) throw op[1];
662
+ return {
663
+ value: op[0] ? op[1] : void 0,
664
+ done: true
665
+ };
666
+ }
667
+ }
668
+ var AbstractWrappedFixture = function AbstractWrappedFixture(fixture) {
669
+ _class_call_check$3(this, AbstractWrappedFixture);
670
+ _define_property$1(this, "fixture", void 0);
671
+ this.fixture = fixture;
672
+ };
673
+ var AbstractWrappedFixtureWithInstance = /*#__PURE__*/ function(AbstractTestContextFixture) {
674
+ _inherits$3(AbstractWrappedFixtureWithInstance, AbstractTestContextFixture);
675
+ function AbstractWrappedFixtureWithInstance(parent) {
676
+ _class_call_check$3(this, AbstractWrappedFixtureWithInstance);
677
+ var _this;
678
+ _this = _call_super$3(this, AbstractWrappedFixtureWithInstance), _define_property$1(_this, "parent", void 0);
679
+ _this.parent = parent;
680
+ return _this;
681
+ }
682
+ return AbstractWrappedFixtureWithInstance;
683
+ }(AbstractTestContextFixture);
188
684
  /**
189
685
  * Wraps the input TestContextFactory to emit another type of Fixture for tests.
190
686
  *
191
687
  * @returns
192
- */
193
- function wrapTestContextFactory(config) {
194
- return factory => {
195
- return buildTests => {
196
- factory(inputFixture => {
197
- const wrap = config.wrapFixture(inputFixture);
198
- let effect;
199
- // add before each
200
- if (config.setupWrap != null) {
201
- beforeEach(async () => {
202
- effect = await config.setupWrap(wrap);
203
- });
204
- }
205
- // add tests
206
- buildTests(wrap);
207
- // add after each
208
- if (config.teardownWrap != null) {
209
- afterEach(async () => {
210
- await config.teardownWrap(wrap, effect);
211
- });
212
- }
213
- });
688
+ */ function wrapTestContextFactory(config) {
689
+ return function(factory) {
690
+ return function(buildTests) {
691
+ factory(function(inputFixture) {
692
+ var wrap = config.wrapFixture(inputFixture);
693
+ var effect;
694
+ // add before each
695
+ if (config.setupWrap != null) {
696
+ beforeEach(function() {
697
+ return _async_to_generator$1(function() {
698
+ return _ts_generator$1(this, function(_state) {
699
+ switch(_state.label){
700
+ case 0:
701
+ return [
702
+ 4,
703
+ config.setupWrap(wrap)
704
+ ];
705
+ case 1:
706
+ effect = _state.sent();
707
+ return [
708
+ 2
709
+ ];
710
+ }
711
+ });
712
+ })();
713
+ });
714
+ }
715
+ // add tests
716
+ buildTests(wrap);
717
+ // add after each
718
+ if (config.teardownWrap != null) {
719
+ afterEach(function() {
720
+ return _async_to_generator$1(function() {
721
+ return _ts_generator$1(this, function(_state) {
722
+ switch(_state.label){
723
+ case 0:
724
+ return [
725
+ 4,
726
+ config.teardownWrap(wrap, effect)
727
+ ];
728
+ case 1:
729
+ _state.sent();
730
+ return [
731
+ 2
732
+ ];
733
+ }
734
+ });
735
+ })();
736
+ });
737
+ }
738
+ });
739
+ };
214
740
  };
215
- };
216
741
  }
217
742
  function instanceWrapTestContextFactory(config) {
218
- return wrapTestContextFactory({
219
- wrapFixture: config.wrapFixture,
220
- setupWrap: async wrap => {
221
- const instance = await config.makeInstance(wrap);
222
- const effect = wrap.setInstance(instance);
223
- if (config.setupInstance) {
224
- await config.setupInstance(instance, wrap);
225
- }
226
- return effect;
227
- },
228
- teardownWrap: async (wrap, deleteInstanceEffect) => {
229
- deleteInstanceEffect?.();
230
- if (config.teardownInstance) {
231
- await config.teardownInstance(wrap.instance);
232
- }
233
- }
234
- });
743
+ return wrapTestContextFactory({
744
+ wrapFixture: config.wrapFixture,
745
+ setupWrap: function setupWrap(wrap) {
746
+ return _async_to_generator$1(function() {
747
+ var instance, effect;
748
+ return _ts_generator$1(this, function(_state) {
749
+ switch(_state.label){
750
+ case 0:
751
+ return [
752
+ 4,
753
+ config.makeInstance(wrap)
754
+ ];
755
+ case 1:
756
+ instance = _state.sent();
757
+ effect = wrap.setInstance(instance);
758
+ if (!config.setupInstance) return [
759
+ 3,
760
+ 3
761
+ ];
762
+ return [
763
+ 4,
764
+ config.setupInstance(instance, wrap)
765
+ ];
766
+ case 2:
767
+ _state.sent();
768
+ _state.label = 3;
769
+ case 3:
770
+ return [
771
+ 2,
772
+ effect
773
+ ];
774
+ }
775
+ });
776
+ })();
777
+ },
778
+ teardownWrap: function teardownWrap(wrap, deleteInstanceEffect) {
779
+ return _async_to_generator$1(function() {
780
+ return _ts_generator$1(this, function(_state) {
781
+ switch(_state.label){
782
+ case 0:
783
+ deleteInstanceEffect === null || deleteInstanceEffect === void 0 ? void 0 : deleteInstanceEffect();
784
+ if (!config.teardownInstance) return [
785
+ 3,
786
+ 2
787
+ ];
788
+ return [
789
+ 4,
790
+ config.teardownInstance(wrap.instance)
791
+ ];
792
+ case 1:
793
+ _state.sent();
794
+ _state.label = 2;
795
+ case 2:
796
+ return [
797
+ 2
798
+ ];
799
+ }
800
+ });
801
+ })();
802
+ }
803
+ });
235
804
  }
236
805
 
237
806
  /**
238
807
  * Creates a test context and configurations that provides a function to build tests based on the configuration.
239
- */
240
- function useTestFunctionFixture(config, buildTests) {
241
- const {
242
- fn
243
- } = config;
244
- const forward = util.forwardFunction(fn);
245
- buildTests(forward);
808
+ */ function useTestFunctionFixture(config, buildTests) {
809
+ var fn = config.fn;
810
+ var forward = util.forwardFunction(fn);
811
+ buildTests(forward);
246
812
  }
247
813
  /**
248
814
  * Creates a test context and configurations that provides a function to build tests based on the configuration.
249
- */
250
- function useTestFunctionMapFixture(config, buildTests) {
251
- const forwardedFunctions = util.mapObjectMap(config.fns, fn => util.forwardFunction(fn));
252
- buildTests(forwardedFunctions);
815
+ */ function useTestFunctionMapFixture(config, buildTests) {
816
+ var forwardedFunctions = util.mapObjectMap(config.fns, function(fn) {
817
+ return util.forwardFunction(fn);
818
+ });
819
+ buildTests(forwardedFunctions);
253
820
  }
254
821
 
255
- var makeError = {exports: {}};
256
-
257
- (function (module, exports$1) {
258
-
259
- // ===================================================================
260
-
261
- var construct = typeof Reflect !== "undefined" ? Reflect.construct : undefined;
262
- var defineProperty = Object.defineProperty;
263
-
264
- // -------------------------------------------------------------------
265
-
266
- var captureStackTrace = Error.captureStackTrace;
267
- if (captureStackTrace === undefined) {
268
- captureStackTrace = function captureStackTrace(error) {
269
- var container = new Error();
270
-
271
- defineProperty(error, "stack", {
272
- configurable: true,
273
- get: function getStack() {
274
- var stack = container.stack;
275
-
276
- // Replace property with value for faster future accesses.
277
- defineProperty(this, "stack", {
278
- configurable: true,
279
- value: stack,
280
- writable: true,
281
- });
282
-
283
- return stack;
284
- },
285
- set: function setStack(stack) {
286
- defineProperty(error, "stack", {
287
- configurable: true,
288
- value: stack,
289
- writable: true,
290
- });
291
- },
292
- });
293
- };
294
- }
295
-
296
- // -------------------------------------------------------------------
297
-
298
- function BaseError(message) {
299
- if (message !== undefined) {
300
- defineProperty(this, "message", {
301
- configurable: true,
302
- value: message,
303
- writable: true,
304
- });
305
- }
306
-
307
- var cname = this.constructor.name;
308
- if (cname !== undefined && cname !== this.name) {
309
- defineProperty(this, "name", {
310
- configurable: true,
311
- value: cname,
312
- writable: true,
313
- });
314
- }
315
-
316
- captureStackTrace(this, this.constructor);
317
- }
318
-
319
- BaseError.prototype = Object.create(Error.prototype, {
320
- // See: https://github.com/JsCommunity/make-error/issues/4
321
- constructor: {
322
- configurable: true,
323
- value: BaseError,
324
- writable: true,
325
- },
326
- });
327
-
328
- // -------------------------------------------------------------------
329
-
330
- // Sets the name of a function if possible (depends of the JS engine).
331
- var setFunctionName = (function() {
332
- function setFunctionName(fn, name) {
333
- return defineProperty(fn, "name", {
334
- configurable: true,
335
- value: name,
336
- });
337
- }
338
- try {
339
- var f = function() {};
340
- setFunctionName(f, "foo");
341
- if (f.name === "foo") {
342
- return setFunctionName;
343
- }
344
- } catch (_) {}
345
- })();
346
-
347
- // -------------------------------------------------------------------
348
-
349
- function makeError(constructor, super_) {
350
- if (super_ == null || super_ === Error) {
351
- super_ = BaseError;
352
- } else if (typeof super_ !== "function") {
353
- throw new TypeError("super_ should be a function");
354
- }
355
-
356
- var name;
357
- if (typeof constructor === "string") {
358
- name = constructor;
359
- constructor =
360
- construct !== undefined
361
- ? function() {
362
- return construct(super_, arguments, this.constructor);
363
- }
364
- : function() {
365
- super_.apply(this, arguments);
366
- };
367
-
368
- // If the name can be set, do it once and for all.
369
- if (setFunctionName !== undefined) {
370
- setFunctionName(constructor, name);
371
- name = undefined;
372
- }
373
- } else if (typeof constructor !== "function") {
374
- throw new TypeError("constructor should be either a string or a function");
375
- }
376
-
377
- // Also register the super constructor also as `constructor.super_` just
378
- // like Node's `util.inherits()`.
379
- //
380
- // eslint-disable-next-line dot-notation
381
- constructor.super_ = constructor["super"] = super_;
382
-
383
- var properties = {
384
- constructor: {
385
- configurable: true,
386
- value: constructor,
387
- writable: true,
388
- },
389
- };
390
-
391
- // If the name could not be set on the constructor, set it on the
392
- // prototype.
393
- if (name !== undefined) {
394
- properties.name = {
395
- configurable: true,
396
- value: name,
397
- writable: true,
398
- };
399
- }
400
- constructor.prototype = Object.create(super_.prototype, properties);
401
-
402
- return constructor;
403
- }
404
- exports$1 = module.exports = makeError;
405
- exports$1.BaseError = BaseError;
406
- } (makeError, makeError.exports));
407
-
408
- var makeErrorExports = makeError.exports;
409
-
410
- /**
411
- * Testing utilities for handling expected failures and errors.
412
- */
822
+ function _assert_this_initialized$2(self) {
823
+ if (self === void 0) {
824
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
825
+ }
826
+ return self;
827
+ }
828
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
829
+ try {
830
+ var info = gen[key](arg);
831
+ var value = info.value;
832
+ } catch (error) {
833
+ reject(error);
834
+ return;
835
+ }
836
+ if (info.done) {
837
+ resolve(value);
838
+ } else {
839
+ Promise.resolve(value).then(_next, _throw);
840
+ }
841
+ }
842
+ function _async_to_generator(fn) {
843
+ return function() {
844
+ var self = this, args = arguments;
845
+ return new Promise(function(resolve, reject) {
846
+ var gen = fn.apply(self, args);
847
+ function _next(value) {
848
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
849
+ }
850
+ function _throw(err) {
851
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
852
+ }
853
+ _next(undefined);
854
+ });
855
+ };
856
+ }
857
+ function _call_super$2(_this, derived, args) {
858
+ derived = _get_prototype_of$2(derived);
859
+ return _possible_constructor_return$2(_this, _is_native_reflect_construct$2() ? Reflect.construct(derived, args || [], _get_prototype_of$2(_this).constructor) : derived.apply(_this, args));
860
+ }
861
+ function _class_call_check$2(instance, Constructor) {
862
+ if (!(instance instanceof Constructor)) {
863
+ throw new TypeError("Cannot call a class as a function");
864
+ }
865
+ }
866
+ function _define_property(obj, key, value) {
867
+ if (key in obj) {
868
+ Object.defineProperty(obj, key, {
869
+ value: value,
870
+ enumerable: true,
871
+ configurable: true,
872
+ writable: true
873
+ });
874
+ } else {
875
+ obj[key] = value;
876
+ }
877
+ return obj;
878
+ }
879
+ function _get_prototype_of$2(o) {
880
+ _get_prototype_of$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
881
+ return o.__proto__ || Object.getPrototypeOf(o);
882
+ };
883
+ return _get_prototype_of$2(o);
884
+ }
885
+ function _inherits$2(subClass, superClass) {
886
+ if (typeof superClass !== "function" && superClass !== null) {
887
+ throw new TypeError("Super expression must either be null or a function");
888
+ }
889
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
890
+ constructor: {
891
+ value: subClass,
892
+ writable: true,
893
+ configurable: true
894
+ }
895
+ });
896
+ if (superClass) _set_prototype_of$2(subClass, superClass);
897
+ }
898
+ function _instanceof(left, right) {
899
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
900
+ return !!right[Symbol.hasInstance](left);
901
+ } else {
902
+ return left instanceof right;
903
+ }
904
+ }
905
+ function _possible_constructor_return$2(self, call) {
906
+ if (call && (_type_of$2(call) === "object" || typeof call === "function")) {
907
+ return call;
908
+ }
909
+ return _assert_this_initialized$2(self);
910
+ }
911
+ function _set_prototype_of$2(o, p) {
912
+ _set_prototype_of$2 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
913
+ o.__proto__ = p;
914
+ return o;
915
+ };
916
+ return _set_prototype_of$2(o, p);
917
+ }
918
+ function _type_of$2(obj) {
919
+ "@swc/helpers - typeof";
920
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
921
+ }
922
+ function _is_native_reflect_construct$2() {
923
+ try {
924
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
925
+ } catch (_) {}
926
+ return (_is_native_reflect_construct$2 = function() {
927
+ return !!result;
928
+ })();
929
+ }
930
+ function _ts_generator(thisArg, body) {
931
+ var f, y, t, _ = {
932
+ label: 0,
933
+ sent: function() {
934
+ if (t[0] & 1) throw t[1];
935
+ return t[1];
936
+ },
937
+ trys: [],
938
+ ops: []
939
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
940
+ return d(g, "next", {
941
+ value: verb(0)
942
+ }), d(g, "throw", {
943
+ value: verb(1)
944
+ }), d(g, "return", {
945
+ value: verb(2)
946
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
947
+ value: function() {
948
+ return this;
949
+ }
950
+ }), g;
951
+ function verb(n) {
952
+ return function(v) {
953
+ return step([
954
+ n,
955
+ v
956
+ ]);
957
+ };
958
+ }
959
+ function step(op) {
960
+ if (f) throw new TypeError("Generator is already executing.");
961
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
962
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
963
+ if (y = 0, t) op = [
964
+ op[0] & 2,
965
+ t.value
966
+ ];
967
+ switch(op[0]){
968
+ case 0:
969
+ case 1:
970
+ t = op;
971
+ break;
972
+ case 4:
973
+ _.label++;
974
+ return {
975
+ value: op[1],
976
+ done: false
977
+ };
978
+ case 5:
979
+ _.label++;
980
+ y = op[1];
981
+ op = [
982
+ 0
983
+ ];
984
+ continue;
985
+ case 7:
986
+ op = _.ops.pop();
987
+ _.trys.pop();
988
+ continue;
989
+ default:
990
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
991
+ _ = 0;
992
+ continue;
993
+ }
994
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
995
+ _.label = op[1];
996
+ break;
997
+ }
998
+ if (op[0] === 6 && _.label < t[1]) {
999
+ _.label = t[1];
1000
+ t = op;
1001
+ break;
1002
+ }
1003
+ if (t && _.label < t[2]) {
1004
+ _.label = t[2];
1005
+ _.ops.push(op);
1006
+ break;
1007
+ }
1008
+ if (t[2]) _.ops.pop();
1009
+ _.trys.pop();
1010
+ continue;
1011
+ }
1012
+ op = body.call(thisArg, _);
1013
+ } catch (e) {
1014
+ op = [
1015
+ 6,
1016
+ e
1017
+ ];
1018
+ y = 0;
1019
+ } finally{
1020
+ f = t = 0;
1021
+ }
1022
+ if (op[0] & 5) throw op[1];
1023
+ return {
1024
+ value: op[0] ? op[1] : void 0,
1025
+ done: true
1026
+ };
1027
+ }
1028
+ }
413
1029
  // MARK: Errors
414
1030
  /**
415
1031
  * Error thrown by fail() and used by expectError()
416
- */
417
- class ExpectedFailError extends makeErrorExports.BaseError {}
1032
+ */ var ExpectedFailError = /*#__PURE__*/ function(BaseError) {
1033
+ _inherits$2(ExpectedFailError, BaseError);
1034
+ function ExpectedFailError() {
1035
+ _class_call_check$2(this, ExpectedFailError);
1036
+ return _call_super$2(this, ExpectedFailError, arguments);
1037
+ }
1038
+ return ExpectedFailError;
1039
+ }(makeError.BaseError);
418
1040
  function failSuccessfullyError(message) {
419
- return new ExpectedFailError(message);
1041
+ return new ExpectedFailError(message);
420
1042
  }
421
1043
  function failSuccessfully(message) {
422
- throw failSuccessfullyError(message);
1044
+ throw failSuccessfullyError(message);
423
1045
  }
424
1046
  /**
425
1047
  * Error thrown when success occurs when it should not have.
426
- */
427
- class UnexpectedSuccessFailureError extends makeErrorExports.BaseError {}
1048
+ */ var UnexpectedSuccessFailureError = /*#__PURE__*/ function(BaseError) {
1049
+ _inherits$2(UnexpectedSuccessFailureError, BaseError);
1050
+ function UnexpectedSuccessFailureError() {
1051
+ _class_call_check$2(this, UnexpectedSuccessFailureError);
1052
+ return _call_super$2(this, UnexpectedSuccessFailureError, arguments);
1053
+ }
1054
+ return UnexpectedSuccessFailureError;
1055
+ }(makeError.BaseError);
428
1056
  function failDueToSuccessError(message) {
429
- return new UnexpectedSuccessFailureError(message ?? 'expected an error to occur but was successful instead');
1057
+ return new UnexpectedSuccessFailureError(message !== null && message !== void 0 ? message : 'expected an error to occur but was successful instead');
430
1058
  }
431
1059
  /**
432
1060
  * Error thrown when the error type was different than the expected type.
433
- */
434
- class ExpectedErrorOfSpecificTypeError extends makeErrorExports.BaseError {
435
- constructor(encounteredType, expectedType) {
436
- super(`The error encountered was not of the expected type. Expected: ${expectedType ?? 'n/a'}, but encountered: ${encounteredType} `);
437
- this.encounteredType = void 0;
438
- this.expectedType = void 0;
439
- this.encounteredType = encounteredType;
440
- this.expectedType = expectedType;
441
- }
442
- }
1061
+ */ var ExpectedErrorOfSpecificTypeError = /*#__PURE__*/ function(BaseError) {
1062
+ _inherits$2(ExpectedErrorOfSpecificTypeError, BaseError);
1063
+ function ExpectedErrorOfSpecificTypeError(encounteredType, expectedType) {
1064
+ _class_call_check$2(this, ExpectedErrorOfSpecificTypeError);
1065
+ var _this;
1066
+ _this = _call_super$2(this, ExpectedErrorOfSpecificTypeError, [
1067
+ "The error encountered was not of the expected type. Expected: ".concat(expectedType !== null && expectedType !== void 0 ? expectedType : 'n/a', ", but encountered: ").concat(encounteredType, " ")
1068
+ ]), _define_property(_this, "encounteredType", void 0), _define_property(_this, "expectedType", void 0);
1069
+ _this.encounteredType = encounteredType;
1070
+ _this.expectedType = expectedType;
1071
+ return _this;
1072
+ }
1073
+ return ExpectedErrorOfSpecificTypeError;
1074
+ }(makeError.BaseError);
443
1075
  function failTest(message) {
444
- throw failDueToSuccessError(message);
1076
+ throw failDueToSuccessError(message);
445
1077
  }
446
1078
  function failDueToSuccess() {
447
- throw failDueToSuccessError();
1079
+ throw failDueToSuccessError();
448
1080
  }
449
1081
  function EXPECT_ERROR_DEFAULT_HANDLER(e) {
450
- if (e instanceof ExpectedFailError) ; else {
451
- throw e;
452
- }
1082
+ if (_instanceof(e, ExpectedFailError)) ; else {
1083
+ throw e;
1084
+ }
453
1085
  }
454
1086
  /**
455
1087
  * Creates an ExpectFailAssertionFunction that asserts the encountered error is of the expected type using the instanceof keyword.
@@ -458,48 +1090,48 @@ function EXPECT_ERROR_DEFAULT_HANDLER(e) {
458
1090
  *
459
1091
  * @param expectedType
460
1092
  * @returns
461
- */
462
- function expectFailAssertErrorType(expectedType) {
463
- return error => {
464
- if (!(error instanceof expectedType)) {
465
- throw new ExpectedErrorOfSpecificTypeError(error, expectedType);
466
- }
467
- };
1093
+ */ function expectFailAssertErrorType(expectedType) {
1094
+ return function(error) {
1095
+ if (!_instanceof(error, expectedType)) {
1096
+ throw new ExpectedErrorOfSpecificTypeError(error, expectedType);
1097
+ }
1098
+ };
468
1099
  }
469
1100
  function expectFail(errorFn, assertFailType) {
470
- function handleError(e) {
471
- if (e instanceof UnexpectedSuccessFailureError) {
472
- throw e;
473
- } else {
474
- const assertionResult = assertFailType?.(e);
475
- if (assertionResult === false) {
476
- throw new ExpectedErrorOfSpecificTypeError(e);
477
- }
478
- failSuccessfully();
479
- }
480
- }
481
- try {
482
- const result = errorFn();
483
- if (util.isPromise(result)) {
484
- return result.then(failDueToSuccess).catch(handleError);
485
- } else {
486
- failDueToSuccess();
1101
+ function handleError(e) {
1102
+ if (_instanceof(e, UnexpectedSuccessFailureError)) {
1103
+ throw e;
1104
+ } else {
1105
+ var assertionResult = assertFailType === null || assertFailType === void 0 ? void 0 : assertFailType(e);
1106
+ if (assertionResult === false) {
1107
+ throw new ExpectedErrorOfSpecificTypeError(e);
1108
+ }
1109
+ failSuccessfully();
1110
+ }
1111
+ }
1112
+ try {
1113
+ var result = errorFn();
1114
+ if (util.isPromise(result)) {
1115
+ return result.then(failDueToSuccess).catch(handleError);
1116
+ } else {
1117
+ failDueToSuccess();
1118
+ }
1119
+ } catch (e) {
1120
+ handleError(e);
487
1121
  }
488
- } catch (e) {
489
- handleError(e);
490
- }
491
1122
  }
492
- function expectSuccessfulFail(errorFn, handleError = EXPECT_ERROR_DEFAULT_HANDLER) {
493
- try {
494
- const result = errorFn();
495
- if (util.isPromise(result)) {
496
- return result.then(failDueToSuccess).catch(handleError);
497
- } else {
498
- failDueToSuccess();
1123
+ function expectSuccessfulFail(errorFn) {
1124
+ var handleError = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : EXPECT_ERROR_DEFAULT_HANDLER;
1125
+ try {
1126
+ var result = errorFn();
1127
+ if (util.isPromise(result)) {
1128
+ return result.then(failDueToSuccess).catch(handleError);
1129
+ } else {
1130
+ failDueToSuccess();
1131
+ }
1132
+ } catch (e) {
1133
+ handleError(e);
499
1134
  }
500
- } catch (e) {
501
- handleError(e);
502
- }
503
1135
  }
504
1136
  /**
505
1137
  * Used to wrap a testing function and watch for ExpectedFailError errors in order to pass the test. Other exceptions are treated normally as failures.
@@ -509,159 +1141,297 @@ function expectSuccessfulFail(errorFn, handleError = EXPECT_ERROR_DEFAULT_HANDLE
509
1141
  * @param fn
510
1142
  * @param strict
511
1143
  * @returns
512
- */
513
- function shouldFail(fn) {
514
- const usesDoneCallback = fn.length > 0;
515
- // Return a function that checks arguments at runtime to avoid done callback deprecation warning
516
- return async function () {
517
- const {
518
- done,
519
- _promise
520
- } = testDoneCallbackRef();
521
- function handleError(e) {
522
- if (!(e instanceof ExpectedFailError)) {
523
- failWithTestDoneCallback(done, e);
524
- } else {
525
- done();
526
- }
527
- }
528
- try {
529
- const result = expectSuccessfulFail(() => {
530
- let result;
531
- if (usesDoneCallback) {
532
- const fakeDone = util.build({
533
- base: fakeDoneHandler(),
534
- build: x => {
535
- x.failSuccessfully = () => {
536
- fakeDone(failSuccessfullyError());
537
- };
1144
+ */ function shouldFail(fn) {
1145
+ var usesDoneCallback = fn.length > 0;
1146
+ // Return a function that checks arguments at runtime to avoid done callback deprecation warning
1147
+ return function() {
1148
+ return _async_to_generator(function() {
1149
+ var _testDoneCallbackRef, done, _promise, result;
1150
+ function handleError(e) {
1151
+ if (!_instanceof(e, ExpectedFailError)) {
1152
+ failWithTestDoneCallback(done, e);
1153
+ } else {
1154
+ done();
1155
+ }
538
1156
  }
539
- });
540
- const callbackWithDoneResult = fn(fakeDone);
541
- if (util.isPromise(callbackWithDoneResult)) {
542
- fakeDone.reject(new Error('Configured to use "done" value while returning a promise. Configure your test to use one or the other.'));
543
- }
544
- // return the fake done promise. Done/fail will resolve as a promise.
545
- result = fakeDone._ref.promise;
546
- } else {
547
- result = fn();
548
- }
549
- return result;
550
- }, handleError);
551
- // If expectSuccessfulFail returns a promise, handle it
552
- if (util.isPromise(result)) {
553
- result.catch(handleError);
554
- }
555
- } catch (e) {
556
- // Handle synchronous errors
557
- handleError(e);
558
- }
559
- return _promise.promise;
560
- };
1157
+ return _ts_generator(this, function(_state) {
1158
+ _testDoneCallbackRef = testDoneCallbackRef(), done = _testDoneCallbackRef.done, _promise = _testDoneCallbackRef._promise;
1159
+ try {
1160
+ result = expectSuccessfulFail(function() {
1161
+ var result;
1162
+ if (usesDoneCallback) {
1163
+ var fakeDone = util.build({
1164
+ base: fakeDoneHandler(),
1165
+ build: function build(x) {
1166
+ x.failSuccessfully = function() {
1167
+ fakeDone(failSuccessfullyError());
1168
+ };
1169
+ }
1170
+ });
1171
+ var callbackWithDoneResult = fn(fakeDone);
1172
+ if (util.isPromise(callbackWithDoneResult)) {
1173
+ fakeDone.reject(new Error('Configured to use "done" value while returning a promise. Configure your test to use one or the other.'));
1174
+ }
1175
+ // return the fake done promise. Done/fail will resolve as a promise.
1176
+ result = fakeDone._ref.promise;
1177
+ } else {
1178
+ result = fn();
1179
+ }
1180
+ return result;
1181
+ }, handleError);
1182
+ // If expectSuccessfulFail returns a promise, handle it
1183
+ if (util.isPromise(result)) {
1184
+ result.catch(handleError);
1185
+ }
1186
+ } catch (e) {
1187
+ // Handle synchronous errors
1188
+ handleError(e);
1189
+ }
1190
+ return [
1191
+ 2,
1192
+ _promise.promise
1193
+ ];
1194
+ });
1195
+ })();
1196
+ };
561
1197
  }
562
1198
  function itShouldFail(describeOrFn, fn) {
563
- let description;
564
- if (typeof describeOrFn === 'string') {
565
- description = `should fail ${describeOrFn}`;
566
- } else {
567
- fn = describeOrFn;
568
- description = 'should fail';
569
- }
570
- it(description, shouldFail(fn));
1199
+ var description;
1200
+ if (typeof describeOrFn === 'string') {
1201
+ description = "should fail ".concat(describeOrFn);
1202
+ } else {
1203
+ fn = describeOrFn;
1204
+ description = 'should fail';
1205
+ }
1206
+ it(description, shouldFail(fn));
571
1207
  }
572
1208
  function fakeDoneHandler() {
573
- const promiseRef = util.promiseReference();
574
- const doneHandler = promiseRef.resolve;
575
- const failHandler = e => {
576
- promiseRef.reject(e);
577
- };
578
- const fakeDone = error => {
579
- if (error) {
580
- failHandler(error);
581
- } else {
582
- doneHandler(0);
583
- }
584
- };
585
- fakeDone.fail = error => {
586
- failHandler(error);
587
- };
588
- fakeDone._ref = promiseRef;
589
- fakeDone.promise = promiseRef.promise;
590
- fakeDone.resolve = promiseRef.resolve;
591
- fakeDone.reject = promiseRef.reject;
592
- return fakeDone;
1209
+ var promiseRef = util.promiseReference();
1210
+ var doneHandler = promiseRef.resolve;
1211
+ var failHandler = function failHandler(e) {
1212
+ promiseRef.reject(e);
1213
+ };
1214
+ var fakeDone = function fakeDone(error) {
1215
+ if (error) {
1216
+ failHandler(error);
1217
+ } else {
1218
+ doneHandler(0);
1219
+ }
1220
+ };
1221
+ fakeDone.fail = function(error) {
1222
+ failHandler(error);
1223
+ };
1224
+ fakeDone._ref = promiseRef;
1225
+ fakeDone.promise = promiseRef.promise;
1226
+ fakeDone.resolve = promiseRef.resolve;
1227
+ fakeDone.reject = promiseRef.reject;
1228
+ return fakeDone;
593
1229
  }
594
1230
 
1231
+ function _assert_this_initialized$1(self) {
1232
+ if (self === void 0) {
1233
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1234
+ }
1235
+ return self;
1236
+ }
1237
+ function _call_super$1(_this, derived, args) {
1238
+ derived = _get_prototype_of$1(derived);
1239
+ return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, args || [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
1240
+ }
1241
+ function _class_call_check$1(instance, Constructor) {
1242
+ if (!(instance instanceof Constructor)) {
1243
+ throw new TypeError("Cannot call a class as a function");
1244
+ }
1245
+ }
1246
+ function _get_prototype_of$1(o) {
1247
+ _get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
1248
+ return o.__proto__ || Object.getPrototypeOf(o);
1249
+ };
1250
+ return _get_prototype_of$1(o);
1251
+ }
1252
+ function _inherits$1(subClass, superClass) {
1253
+ if (typeof superClass !== "function" && superClass !== null) {
1254
+ throw new TypeError("Super expression must either be null or a function");
1255
+ }
1256
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1257
+ constructor: {
1258
+ value: subClass,
1259
+ writable: true,
1260
+ configurable: true
1261
+ }
1262
+ });
1263
+ if (superClass) _set_prototype_of$1(subClass, superClass);
1264
+ }
1265
+ function _possible_constructor_return$1(self, call) {
1266
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
1267
+ return call;
1268
+ }
1269
+ return _assert_this_initialized$1(self);
1270
+ }
1271
+ function _set_prototype_of$1(o, p) {
1272
+ _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
1273
+ o.__proto__ = p;
1274
+ return o;
1275
+ };
1276
+ return _set_prototype_of$1(o, p);
1277
+ }
1278
+ function _type_of$1(obj) {
1279
+ "@swc/helpers - typeof";
1280
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1281
+ }
1282
+ function _is_native_reflect_construct$1() {
1283
+ try {
1284
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
1285
+ } catch (_) {}
1286
+ return (_is_native_reflect_construct$1 = function() {
1287
+ return !!result;
1288
+ })();
1289
+ }
595
1290
  /**
596
1291
  * @deprecated Use AbstractTestContextFixture from shared instead. This is kept for backwards compatibility.
597
- */
598
- class AbstractJestTestContextFixture extends AbstractTestContextFixture {}
1292
+ */ var AbstractJestTestContextFixture = /*#__PURE__*/ function(AbstractTestContextFixture) {
1293
+ _inherits$1(AbstractJestTestContextFixture, AbstractTestContextFixture);
1294
+ function AbstractJestTestContextFixture() {
1295
+ _class_call_check$1(this, AbstractJestTestContextFixture);
1296
+ return _call_super$1(this, AbstractJestTestContextFixture, arguments);
1297
+ }
1298
+ return AbstractJestTestContextFixture;
1299
+ }(AbstractTestContextFixture);
599
1300
  /**
600
1301
  * @deprecated Use AbstractChildTestContextFixture from shared instead. This is kept for backwards compatibility.
601
- */
602
- class AbstractChildJestTestContextFixture extends AbstractChildTestContextFixture {}
1302
+ */ var AbstractChildJestTestContextFixture = /*#__PURE__*/ function(AbstractChildTestContextFixture) {
1303
+ _inherits$1(AbstractChildJestTestContextFixture, AbstractChildTestContextFixture);
1304
+ function AbstractChildJestTestContextFixture() {
1305
+ _class_call_check$1(this, AbstractChildJestTestContextFixture);
1306
+ return _call_super$1(this, AbstractChildJestTestContextFixture, arguments);
1307
+ }
1308
+ return AbstractChildJestTestContextFixture;
1309
+ }(AbstractChildTestContextFixture);
603
1310
  /**
604
1311
  * @deprecated Use testContextBuilder from shared instead. This is kept for backwards compatibility.
605
- */
606
- const jestTestContextBuilder = testContextBuilder;
1312
+ */ var jestTestContextBuilder = testContextBuilder;
607
1313
  /**
608
1314
  * @deprecated Use useContextFixture from shared instead. This is kept for backwards compatibility.
609
- */
610
- const useJestContextFixture = useTestContextFixture;
1315
+ */ var useJestContextFixture = useTestContextFixture;
611
1316
 
612
- /**
613
- * https://github.com/facebook/jest/issues/11698
614
- *
615
- * Since fail() was silently removed, we redefine it.
616
- */
1317
+ function _assert_this_initialized(self) {
1318
+ if (self === void 0) {
1319
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1320
+ }
1321
+ return self;
1322
+ }
1323
+ function _call_super(_this, derived, args) {
1324
+ derived = _get_prototype_of(derived);
1325
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
1326
+ }
1327
+ function _class_call_check(instance, Constructor) {
1328
+ if (!(instance instanceof Constructor)) {
1329
+ throw new TypeError("Cannot call a class as a function");
1330
+ }
1331
+ }
1332
+ function _get_prototype_of(o) {
1333
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
1334
+ return o.__proto__ || Object.getPrototypeOf(o);
1335
+ };
1336
+ return _get_prototype_of(o);
1337
+ }
1338
+ function _inherits(subClass, superClass) {
1339
+ if (typeof superClass !== "function" && superClass !== null) {
1340
+ throw new TypeError("Super expression must either be null or a function");
1341
+ }
1342
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1343
+ constructor: {
1344
+ value: subClass,
1345
+ writable: true,
1346
+ configurable: true
1347
+ }
1348
+ });
1349
+ if (superClass) _set_prototype_of(subClass, superClass);
1350
+ }
1351
+ function _possible_constructor_return(self, call) {
1352
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
1353
+ return call;
1354
+ }
1355
+ return _assert_this_initialized(self);
1356
+ }
1357
+ function _set_prototype_of(o, p) {
1358
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
1359
+ o.__proto__ = p;
1360
+ return o;
1361
+ };
1362
+ return _set_prototype_of(o, p);
1363
+ }
1364
+ function _type_of(obj) {
1365
+ "@swc/helpers - typeof";
1366
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1367
+ }
1368
+ function _is_native_reflect_construct() {
1369
+ try {
1370
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
1371
+ } catch (_) {}
1372
+ return (_is_native_reflect_construct = function() {
1373
+ return !!result;
1374
+ })();
1375
+ }
617
1376
  /**
618
1377
  * @deprecated Use failWithTestDoneCallback from shared instead. This is kept for backwards compatibility.
619
- */
620
- const failWithJestDoneCallback = failWithTestDoneCallback;
1378
+ */ var failWithJestDoneCallback = failWithTestDoneCallback;
621
1379
  // MARK: Errors
622
1380
  /**
623
1381
  * @deprecated Use ExpectedFailError from shared instead. This is kept for backwards compatibility.
624
- */
625
- class JestExpectedFailError extends ExpectedFailError {}
1382
+ */ var JestExpectedFailError = /*#__PURE__*/ function(ExpectedFailError) {
1383
+ _inherits(JestExpectedFailError, ExpectedFailError);
1384
+ function JestExpectedFailError() {
1385
+ _class_call_check(this, JestExpectedFailError);
1386
+ return _call_super(this, JestExpectedFailError, arguments);
1387
+ }
1388
+ return JestExpectedFailError;
1389
+ }(ExpectedFailError);
626
1390
  /**
627
1391
  * @deprecated Use UnexpectedSuccessFailureError from shared instead. This is kept for backwards compatibility.
628
- */
629
- class JestUnexpectedSuccessFailureError extends UnexpectedSuccessFailureError {}
1392
+ */ var JestUnexpectedSuccessFailureError = /*#__PURE__*/ function(UnexpectedSuccessFailureError) {
1393
+ _inherits(JestUnexpectedSuccessFailureError, UnexpectedSuccessFailureError);
1394
+ function JestUnexpectedSuccessFailureError() {
1395
+ _class_call_check(this, JestUnexpectedSuccessFailureError);
1396
+ return _call_super(this, JestUnexpectedSuccessFailureError, arguments);
1397
+ }
1398
+ return JestUnexpectedSuccessFailureError;
1399
+ }(UnexpectedSuccessFailureError);
630
1400
  /**
631
1401
  * @deprecated Use ExpectedErrorOfSpecificTypeError from shared instead. This is kept for backwards compatibility.
632
- */
633
- class JestExpectedErrorOfSpecificTypeError extends ExpectedErrorOfSpecificTypeError {}
1402
+ */ var JestExpectedErrorOfSpecificTypeError = /*#__PURE__*/ function(ExpectedErrorOfSpecificTypeError) {
1403
+ _inherits(JestExpectedErrorOfSpecificTypeError, ExpectedErrorOfSpecificTypeError);
1404
+ function JestExpectedErrorOfSpecificTypeError() {
1405
+ _class_call_check(this, JestExpectedErrorOfSpecificTypeError);
1406
+ return _call_super(this, JestExpectedErrorOfSpecificTypeError, arguments);
1407
+ }
1408
+ return JestExpectedErrorOfSpecificTypeError;
1409
+ }(ExpectedErrorOfSpecificTypeError);
634
1410
  /**
635
1411
  * @deprecated Use failWithTestDoneCallback with failDueToSuccessError from shared instead. This is kept for backwards compatibility.
636
- */
637
- function failWithDoneDueToSuccess(done) {
638
- failWithTestDoneCallback(done, failDueToSuccessError());
1412
+ */ function failWithDoneDueToSuccess(done) {
1413
+ failWithTestDoneCallback(done, failDueToSuccessError());
639
1414
  }
640
1415
  /**
641
1416
  * @deprecated Use expectFailAssertErrorType from shared instead. This is kept for backwards compatibility.
642
- */
643
- const jestExpectFailAssertErrorType = expectFailAssertErrorType;
1417
+ */ var jestExpectFailAssertErrorType = expectFailAssertErrorType;
644
1418
 
645
1419
  /**
646
1420
  * Wraps the input JestTestContextFactory to emit another type of Fixture for tests.
647
1421
  *
648
1422
  * @deprecated Use wrapTestContextFactory from shared instead. This is kept for backwards compatibility.
649
1423
  * @returns
650
- */
651
- const wrapJestTestContextFactory = wrapTestContextFactory;
1424
+ */ var wrapJestTestContextFactory = wrapTestContextFactory;
652
1425
  /**
653
1426
  * @deprecated Use instanceWrapTestContextFactory from shared instead. This is kept for backwards compatibility.
654
- */
655
- const instanceWrapJestTestContextFactory = instanceWrapTestContextFactory;
1427
+ */ var instanceWrapJestTestContextFactory = instanceWrapTestContextFactory;
656
1428
 
657
1429
  /**
658
1430
  * @deprecated Use useTestFunctionFixture from shared instead. This is kept for backwards compatibility.
659
- */
660
- const useJestFunctionFixture = useTestFunctionFixture;
1431
+ */ var useJestFunctionFixture = useTestFunctionFixture;
661
1432
  /**
662
1433
  * @deprecated Use useTestFunctionMapFixture from shared instead. This is kept for backwards compatibility.
663
- */
664
- const useJestFunctionMapFixture = useTestFunctionMapFixture;
1434
+ */ var useJestFunctionMapFixture = useTestFunctionMapFixture;
665
1435
 
666
1436
  exports.AbstractChildJestTestContextFixture = AbstractChildJestTestContextFixture;
667
1437
  exports.AbstractChildTestContextFixture = AbstractChildTestContextFixture;