mocha 9.1.2 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/browser-entry.js +26 -16
- package/lib/browser/growl.js +5 -5
- package/lib/browser/parse-query.js +1 -1
- package/lib/browser/progress.js +6 -6
- package/lib/cli/config.js +7 -12
- package/lib/cli/run.js +1 -1
- package/lib/cli/watch-run.js +1 -4
- package/lib/context.js +5 -5
- package/lib/errors.js +1 -1
- package/lib/hook.js +2 -2
- package/lib/interfaces/bdd.js +23 -20
- package/lib/interfaces/common.js +7 -7
- package/lib/interfaces/exports.js +1 -1
- package/lib/interfaces/qunit.js +7 -7
- package/lib/interfaces/tdd.js +9 -9
- package/lib/mocha.js +56 -58
- package/lib/nodejs/buffered-worker-pool.js +17 -1
- package/lib/nodejs/esm-utils.js +18 -3
- package/lib/reporters/base.js +41 -28
- package/lib/reporters/doc.js +4 -4
- package/lib/reporters/dot.js +5 -5
- package/lib/reporters/html.js +12 -12
- package/lib/reporters/json-stream.js +4 -4
- package/lib/reporters/json.js +7 -7
- package/lib/reporters/landing.js +5 -5
- package/lib/reporters/list.js +5 -5
- package/lib/reporters/markdown.js +5 -5
- package/lib/reporters/min.js +1 -1
- package/lib/reporters/nyan.js +16 -16
- package/lib/reporters/progress.js +3 -3
- package/lib/reporters/spec.js +6 -6
- package/lib/reporters/tap.js +17 -17
- package/lib/reporters/xunit.js +9 -9
- package/lib/runnable.js +21 -21
- package/lib/runner.js +44 -47
- package/lib/stats-collector.js +7 -7
- package/lib/suite.js +44 -73
- package/lib/test.js +4 -4
- package/lib/utils.js +18 -19
- package/mocha-es2018.js +432 -449
- package/mocha.js +1246 -851
- package/mocha.js.map +1 -1
- package/package.json +38 -38
- package/CHANGELOG.md +0 -1015
package/lib/suite.js
CHANGED
|
@@ -10,7 +10,6 @@ var {
|
|
|
10
10
|
assignNewMochaID,
|
|
11
11
|
clamp,
|
|
12
12
|
constants: utilsConstants,
|
|
13
|
-
createMap,
|
|
14
13
|
defineConstants,
|
|
15
14
|
getMochaID,
|
|
16
15
|
inherits,
|
|
@@ -36,7 +35,7 @@ exports = module.exports = Suite;
|
|
|
36
35
|
* @param {string} title - Title
|
|
37
36
|
* @return {Suite}
|
|
38
37
|
*/
|
|
39
|
-
Suite.create = function(parent, title) {
|
|
38
|
+
Suite.create = function (parent, title) {
|
|
40
39
|
var suite = new Suite(title, parent.ctx);
|
|
41
40
|
suite.parent = parent;
|
|
42
41
|
title = suite.fullTitle();
|
|
@@ -92,16 +91,6 @@ function Suite(title, parentContext, isRoot) {
|
|
|
92
91
|
});
|
|
93
92
|
|
|
94
93
|
this.reset();
|
|
95
|
-
|
|
96
|
-
this.on('newListener', function(event) {
|
|
97
|
-
if (deprecatedEvents[event]) {
|
|
98
|
-
errors.deprecate(
|
|
99
|
-
'Event "' +
|
|
100
|
-
event +
|
|
101
|
-
'" is deprecated. Please let the Mocha team know about your use case: https://git.io/v6Lwm'
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
94
|
}
|
|
106
95
|
|
|
107
96
|
/**
|
|
@@ -112,7 +101,7 @@ inherits(Suite, EventEmitter);
|
|
|
112
101
|
/**
|
|
113
102
|
* Resets the state initially or for a next run.
|
|
114
103
|
*/
|
|
115
|
-
Suite.prototype.reset = function() {
|
|
104
|
+
Suite.prototype.reset = function () {
|
|
116
105
|
this.delayed = false;
|
|
117
106
|
function doReset(thingToReset) {
|
|
118
107
|
thingToReset.reset();
|
|
@@ -131,7 +120,7 @@ Suite.prototype.reset = function() {
|
|
|
131
120
|
* @private
|
|
132
121
|
* @return {Suite}
|
|
133
122
|
*/
|
|
134
|
-
Suite.prototype.clone = function() {
|
|
123
|
+
Suite.prototype.clone = function () {
|
|
135
124
|
var suite = new Suite(this.title);
|
|
136
125
|
debug('clone');
|
|
137
126
|
suite.ctx = this.ctx;
|
|
@@ -151,7 +140,7 @@ Suite.prototype.clone = function() {
|
|
|
151
140
|
* @param {number|string} ms
|
|
152
141
|
* @return {Suite|number} for chaining
|
|
153
142
|
*/
|
|
154
|
-
Suite.prototype.timeout = function(ms) {
|
|
143
|
+
Suite.prototype.timeout = function (ms) {
|
|
155
144
|
if (!arguments.length) {
|
|
156
145
|
return this._timeout;
|
|
157
146
|
}
|
|
@@ -176,7 +165,7 @@ Suite.prototype.timeout = function(ms) {
|
|
|
176
165
|
* @param {number|string} n
|
|
177
166
|
* @return {Suite|number} for chaining
|
|
178
167
|
*/
|
|
179
|
-
Suite.prototype.retries = function(n) {
|
|
168
|
+
Suite.prototype.retries = function (n) {
|
|
180
169
|
if (!arguments.length) {
|
|
181
170
|
return this._retries;
|
|
182
171
|
}
|
|
@@ -192,7 +181,7 @@ Suite.prototype.retries = function(n) {
|
|
|
192
181
|
* @param {number|string} ms
|
|
193
182
|
* @return {Suite|number} for chaining
|
|
194
183
|
*/
|
|
195
|
-
Suite.prototype.slow = function(ms) {
|
|
184
|
+
Suite.prototype.slow = function (ms) {
|
|
196
185
|
if (!arguments.length) {
|
|
197
186
|
return this._slow;
|
|
198
187
|
}
|
|
@@ -211,7 +200,7 @@ Suite.prototype.slow = function(ms) {
|
|
|
211
200
|
* @param {boolean} bail
|
|
212
201
|
* @return {Suite|number} for chaining
|
|
213
202
|
*/
|
|
214
|
-
Suite.prototype.bail = function(bail) {
|
|
203
|
+
Suite.prototype.bail = function (bail) {
|
|
215
204
|
if (!arguments.length) {
|
|
216
205
|
return this._bail;
|
|
217
206
|
}
|
|
@@ -225,7 +214,7 @@ Suite.prototype.bail = function(bail) {
|
|
|
225
214
|
*
|
|
226
215
|
* @private
|
|
227
216
|
*/
|
|
228
|
-
Suite.prototype.isPending = function() {
|
|
217
|
+
Suite.prototype.isPending = function () {
|
|
229
218
|
return this.pending || (this.parent && this.parent.isPending());
|
|
230
219
|
};
|
|
231
220
|
|
|
@@ -236,7 +225,7 @@ Suite.prototype.isPending = function() {
|
|
|
236
225
|
* @param {Function} fn - Hook callback
|
|
237
226
|
* @returns {Hook} A new hook
|
|
238
227
|
*/
|
|
239
|
-
Suite.prototype._createHook = function(title, fn) {
|
|
228
|
+
Suite.prototype._createHook = function (title, fn) {
|
|
240
229
|
var hook = new Hook(title, fn);
|
|
241
230
|
hook.parent = this;
|
|
242
231
|
hook.timeout(this.timeout());
|
|
@@ -255,7 +244,7 @@ Suite.prototype._createHook = function(title, fn) {
|
|
|
255
244
|
* @param {Function} fn
|
|
256
245
|
* @return {Suite} for chaining
|
|
257
246
|
*/
|
|
258
|
-
Suite.prototype.beforeAll = function(title, fn) {
|
|
247
|
+
Suite.prototype.beforeAll = function (title, fn) {
|
|
259
248
|
if (this.isPending()) {
|
|
260
249
|
return this;
|
|
261
250
|
}
|
|
@@ -279,7 +268,7 @@ Suite.prototype.beforeAll = function(title, fn) {
|
|
|
279
268
|
* @param {Function} fn
|
|
280
269
|
* @return {Suite} for chaining
|
|
281
270
|
*/
|
|
282
|
-
Suite.prototype.afterAll = function(title, fn) {
|
|
271
|
+
Suite.prototype.afterAll = function (title, fn) {
|
|
283
272
|
if (this.isPending()) {
|
|
284
273
|
return this;
|
|
285
274
|
}
|
|
@@ -303,7 +292,7 @@ Suite.prototype.afterAll = function(title, fn) {
|
|
|
303
292
|
* @param {Function} fn
|
|
304
293
|
* @return {Suite} for chaining
|
|
305
294
|
*/
|
|
306
|
-
Suite.prototype.beforeEach = function(title, fn) {
|
|
295
|
+
Suite.prototype.beforeEach = function (title, fn) {
|
|
307
296
|
if (this.isPending()) {
|
|
308
297
|
return this;
|
|
309
298
|
}
|
|
@@ -327,7 +316,7 @@ Suite.prototype.beforeEach = function(title, fn) {
|
|
|
327
316
|
* @param {Function} fn
|
|
328
317
|
* @return {Suite} for chaining
|
|
329
318
|
*/
|
|
330
|
-
Suite.prototype.afterEach = function(title, fn) {
|
|
319
|
+
Suite.prototype.afterEach = function (title, fn) {
|
|
331
320
|
if (this.isPending()) {
|
|
332
321
|
return this;
|
|
333
322
|
}
|
|
@@ -350,7 +339,7 @@ Suite.prototype.afterEach = function(title, fn) {
|
|
|
350
339
|
* @param {Suite} suite
|
|
351
340
|
* @return {Suite} for chaining
|
|
352
341
|
*/
|
|
353
|
-
Suite.prototype.addSuite = function(suite) {
|
|
342
|
+
Suite.prototype.addSuite = function (suite) {
|
|
354
343
|
suite.parent = this;
|
|
355
344
|
suite.root = false;
|
|
356
345
|
suite.timeout(this.timeout());
|
|
@@ -369,7 +358,7 @@ Suite.prototype.addSuite = function(suite) {
|
|
|
369
358
|
* @param {Test} test
|
|
370
359
|
* @return {Suite} for chaining
|
|
371
360
|
*/
|
|
372
|
-
Suite.prototype.addTest = function(test) {
|
|
361
|
+
Suite.prototype.addTest = function (test) {
|
|
373
362
|
test.parent = this;
|
|
374
363
|
test.timeout(this.timeout());
|
|
375
364
|
test.retries(this.retries());
|
|
@@ -388,7 +377,7 @@ Suite.prototype.addTest = function(test) {
|
|
|
388
377
|
* @public
|
|
389
378
|
* @return {string}
|
|
390
379
|
*/
|
|
391
|
-
Suite.prototype.fullTitle = function() {
|
|
380
|
+
Suite.prototype.fullTitle = function () {
|
|
392
381
|
return this.titlePath().join(' ');
|
|
393
382
|
};
|
|
394
383
|
|
|
@@ -400,7 +389,7 @@ Suite.prototype.fullTitle = function() {
|
|
|
400
389
|
* @public
|
|
401
390
|
* @return {string}
|
|
402
391
|
*/
|
|
403
|
-
Suite.prototype.titlePath = function() {
|
|
392
|
+
Suite.prototype.titlePath = function () {
|
|
404
393
|
var result = [];
|
|
405
394
|
if (this.parent) {
|
|
406
395
|
result = result.concat(this.parent.titlePath());
|
|
@@ -418,9 +407,9 @@ Suite.prototype.titlePath = function() {
|
|
|
418
407
|
* @public
|
|
419
408
|
* @return {number}
|
|
420
409
|
*/
|
|
421
|
-
Suite.prototype.total = function() {
|
|
410
|
+
Suite.prototype.total = function () {
|
|
422
411
|
return (
|
|
423
|
-
this.suites.reduce(function(sum, suite) {
|
|
412
|
+
this.suites.reduce(function (sum, suite) {
|
|
424
413
|
return sum + suite.total();
|
|
425
414
|
}, 0) + this.tests.length
|
|
426
415
|
);
|
|
@@ -434,9 +423,9 @@ Suite.prototype.total = function() {
|
|
|
434
423
|
* @param {Function} fn
|
|
435
424
|
* @return {Suite}
|
|
436
425
|
*/
|
|
437
|
-
Suite.prototype.eachTest = function(fn) {
|
|
426
|
+
Suite.prototype.eachTest = function (fn) {
|
|
438
427
|
this.tests.forEach(fn);
|
|
439
|
-
this.suites.forEach(function(suite) {
|
|
428
|
+
this.suites.forEach(function (suite) {
|
|
440
429
|
suite.eachTest(fn);
|
|
441
430
|
});
|
|
442
431
|
return this;
|
|
@@ -462,7 +451,7 @@ Suite.prototype.hasOnly = function hasOnly() {
|
|
|
462
451
|
return (
|
|
463
452
|
this._onlyTests.length > 0 ||
|
|
464
453
|
this._onlySuites.length > 0 ||
|
|
465
|
-
this.suites.some(function(suite) {
|
|
454
|
+
this.suites.some(function (suite) {
|
|
466
455
|
return suite.hasOnly();
|
|
467
456
|
})
|
|
468
457
|
);
|
|
@@ -482,7 +471,7 @@ Suite.prototype.filterOnly = function filterOnly() {
|
|
|
482
471
|
} else {
|
|
483
472
|
// Otherwise, do not run any of the tests in this suite.
|
|
484
473
|
this.tests = [];
|
|
485
|
-
this._onlySuites.forEach(function(onlySuite) {
|
|
474
|
+
this._onlySuites.forEach(function (onlySuite) {
|
|
486
475
|
// If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
|
|
487
476
|
// Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
|
|
488
477
|
if (onlySuite.hasOnly()) {
|
|
@@ -491,7 +480,7 @@ Suite.prototype.filterOnly = function filterOnly() {
|
|
|
491
480
|
});
|
|
492
481
|
// Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
|
|
493
482
|
var onlySuites = this._onlySuites;
|
|
494
|
-
this.suites = this.suites.filter(function(childSuite) {
|
|
483
|
+
this.suites = this.suites.filter(function (childSuite) {
|
|
495
484
|
return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly();
|
|
496
485
|
});
|
|
497
486
|
}
|
|
@@ -505,7 +494,7 @@ Suite.prototype.filterOnly = function filterOnly() {
|
|
|
505
494
|
* @private
|
|
506
495
|
* @param {Suite} suite
|
|
507
496
|
*/
|
|
508
|
-
Suite.prototype.appendOnlySuite = function(suite) {
|
|
497
|
+
Suite.prototype.appendOnlySuite = function (suite) {
|
|
509
498
|
this._onlySuites.push(suite);
|
|
510
499
|
};
|
|
511
500
|
|
|
@@ -514,7 +503,7 @@ Suite.prototype.appendOnlySuite = function(suite) {
|
|
|
514
503
|
*
|
|
515
504
|
* @private
|
|
516
505
|
*/
|
|
517
|
-
Suite.prototype.markOnly = function() {
|
|
506
|
+
Suite.prototype.markOnly = function () {
|
|
518
507
|
this.parent && this.parent.appendOnlySuite(this);
|
|
519
508
|
};
|
|
520
509
|
|
|
@@ -524,7 +513,7 @@ Suite.prototype.markOnly = function() {
|
|
|
524
513
|
* @private
|
|
525
514
|
* @param {Test} test
|
|
526
515
|
*/
|
|
527
|
-
Suite.prototype.appendOnlyTest = function(test) {
|
|
516
|
+
Suite.prototype.appendOnlyTest = function (test) {
|
|
528
517
|
this._onlyTests.push(test);
|
|
529
518
|
};
|
|
530
519
|
|
|
@@ -539,8 +528,8 @@ Suite.prototype.getHooks = function getHooks(name) {
|
|
|
539
528
|
/**
|
|
540
529
|
* cleans all references from this suite and all child suites.
|
|
541
530
|
*/
|
|
542
|
-
Suite.prototype.dispose = function() {
|
|
543
|
-
this.suites.forEach(function(suite) {
|
|
531
|
+
Suite.prototype.dispose = function () {
|
|
532
|
+
this.suites.forEach(function (suite) {
|
|
544
533
|
suite.dispose();
|
|
545
534
|
});
|
|
546
535
|
this.cleanReferences();
|
|
@@ -614,7 +603,7 @@ var constants = defineConstants(
|
|
|
614
603
|
*/
|
|
615
604
|
{
|
|
616
605
|
/**
|
|
617
|
-
* Event emitted after a test file has been loaded Not emitted in browser.
|
|
606
|
+
* Event emitted after a test file has been loaded. Not emitted in browser.
|
|
618
607
|
*/
|
|
619
608
|
EVENT_FILE_POST_REQUIRE: 'post-require',
|
|
620
609
|
/**
|
|
@@ -626,70 +615,52 @@ var constants = defineConstants(
|
|
|
626
615
|
*/
|
|
627
616
|
EVENT_FILE_REQUIRE: 'require',
|
|
628
617
|
/**
|
|
629
|
-
* Event emitted when `global.run()` is called (use with `delay` option)
|
|
618
|
+
* Event emitted when `global.run()` is called (use with `delay` option).
|
|
630
619
|
*/
|
|
631
620
|
EVENT_ROOT_SUITE_RUN: 'run',
|
|
632
621
|
|
|
633
622
|
/**
|
|
634
|
-
* Namespace for collection of a `Suite`'s "after all" hooks
|
|
623
|
+
* Namespace for collection of a `Suite`'s "after all" hooks.
|
|
635
624
|
*/
|
|
636
625
|
HOOK_TYPE_AFTER_ALL: 'afterAll',
|
|
637
626
|
/**
|
|
638
|
-
* Namespace for collection of a `Suite`'s "after each" hooks
|
|
627
|
+
* Namespace for collection of a `Suite`'s "after each" hooks.
|
|
639
628
|
*/
|
|
640
629
|
HOOK_TYPE_AFTER_EACH: 'afterEach',
|
|
641
630
|
/**
|
|
642
|
-
* Namespace for collection of a `Suite`'s "before all" hooks
|
|
631
|
+
* Namespace for collection of a `Suite`'s "before all" hooks.
|
|
643
632
|
*/
|
|
644
633
|
HOOK_TYPE_BEFORE_ALL: 'beforeAll',
|
|
645
634
|
/**
|
|
646
|
-
* Namespace for collection of a `Suite`'s "before
|
|
635
|
+
* Namespace for collection of a `Suite`'s "before each" hooks.
|
|
647
636
|
*/
|
|
648
637
|
HOOK_TYPE_BEFORE_EACH: 'beforeEach',
|
|
649
638
|
|
|
650
|
-
// the following events are all deprecated
|
|
651
|
-
|
|
652
639
|
/**
|
|
653
|
-
* Emitted after
|
|
640
|
+
* Emitted after a child `Suite` has been added to a `Suite`.
|
|
641
|
+
*/
|
|
642
|
+
EVENT_SUITE_ADD_SUITE: 'suite',
|
|
643
|
+
/**
|
|
644
|
+
* Emitted after an "after all" `Hook` has been added to a `Suite`.
|
|
654
645
|
*/
|
|
655
646
|
EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll',
|
|
656
647
|
/**
|
|
657
|
-
* Emitted after an "after each" `Hook` has been added to a `Suite
|
|
648
|
+
* Emitted after an "after each" `Hook` has been added to a `Suite`.
|
|
658
649
|
*/
|
|
659
650
|
EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach',
|
|
660
651
|
/**
|
|
661
|
-
* Emitted after an "before all" `Hook` has been added to a `Suite
|
|
652
|
+
* Emitted after an "before all" `Hook` has been added to a `Suite`.
|
|
662
653
|
*/
|
|
663
654
|
EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll',
|
|
664
655
|
/**
|
|
665
|
-
* Emitted after an "before each" `Hook` has been added to a `Suite
|
|
656
|
+
* Emitted after an "before each" `Hook` has been added to a `Suite`.
|
|
666
657
|
*/
|
|
667
658
|
EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach',
|
|
668
659
|
/**
|
|
669
|
-
* Emitted after a
|
|
670
|
-
*/
|
|
671
|
-
EVENT_SUITE_ADD_SUITE: 'suite',
|
|
672
|
-
/**
|
|
673
|
-
* Emitted after a `Test` has been added to a `Suite`. Deprecated
|
|
660
|
+
* Emitted after a `Test` has been added to a `Suite`.
|
|
674
661
|
*/
|
|
675
662
|
EVENT_SUITE_ADD_TEST: 'test'
|
|
676
663
|
}
|
|
677
664
|
);
|
|
678
665
|
|
|
679
|
-
/**
|
|
680
|
-
* @summary There are no known use cases for these events.
|
|
681
|
-
* @desc This is a `Set`-like object having all keys being the constant's string value and the value being `true`.
|
|
682
|
-
* @todo Remove eventually
|
|
683
|
-
* @type {Object<string,boolean>}
|
|
684
|
-
* @ignore
|
|
685
|
-
*/
|
|
686
|
-
var deprecatedEvents = Object.keys(constants)
|
|
687
|
-
.filter(function(constant) {
|
|
688
|
-
return constant.substring(0, 15) === 'EVENT_SUITE_ADD';
|
|
689
|
-
})
|
|
690
|
-
.reduce(function(acc, constant) {
|
|
691
|
-
acc[constants[constant]] = true;
|
|
692
|
-
return acc;
|
|
693
|
-
}, createMap());
|
|
694
|
-
|
|
695
666
|
Suite.constants = constants;
|
package/lib/test.js
CHANGED
|
@@ -41,7 +41,7 @@ utils.inherits(Test, Runnable);
|
|
|
41
41
|
/**
|
|
42
42
|
* Resets the state initially or for a next run.
|
|
43
43
|
*/
|
|
44
|
-
Test.prototype.reset = function() {
|
|
44
|
+
Test.prototype.reset = function () {
|
|
45
45
|
Runnable.prototype.reset.call(this);
|
|
46
46
|
this.pending = !this.fn;
|
|
47
47
|
delete this.state;
|
|
@@ -52,7 +52,7 @@ Test.prototype.reset = function() {
|
|
|
52
52
|
*
|
|
53
53
|
* @private
|
|
54
54
|
*/
|
|
55
|
-
Test.prototype.retriedTest = function(n) {
|
|
55
|
+
Test.prototype.retriedTest = function (n) {
|
|
56
56
|
if (!arguments.length) {
|
|
57
57
|
return this._retriedTest;
|
|
58
58
|
}
|
|
@@ -64,11 +64,11 @@ Test.prototype.retriedTest = function(n) {
|
|
|
64
64
|
*
|
|
65
65
|
* @private
|
|
66
66
|
*/
|
|
67
|
-
Test.prototype.markOnly = function() {
|
|
67
|
+
Test.prototype.markOnly = function () {
|
|
68
68
|
this.parent.appendOnlyTest(this);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
Test.prototype.clone = function() {
|
|
71
|
+
Test.prototype.clone = function () {
|
|
72
72
|
var test = new Test(this.title, this.fn);
|
|
73
73
|
test.timeout(this.timeout());
|
|
74
74
|
test.slow(this.slow());
|
package/lib/utils.js
CHANGED
|
@@ -34,7 +34,7 @@ exports.inherits = util.inherits;
|
|
|
34
34
|
* @param {string} html
|
|
35
35
|
* @return {string}
|
|
36
36
|
*/
|
|
37
|
-
exports.escape = function(html) {
|
|
37
|
+
exports.escape = function (html) {
|
|
38
38
|
return he.encode(String(html), {useNamedReferences: false});
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -45,7 +45,7 @@ exports.escape = function(html) {
|
|
|
45
45
|
* @param {Object} obj
|
|
46
46
|
* @return {boolean}
|
|
47
47
|
*/
|
|
48
|
-
exports.isString = function(obj) {
|
|
48
|
+
exports.isString = function (obj) {
|
|
49
49
|
return typeof obj === 'string';
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ exports.isString = function(obj) {
|
|
|
56
56
|
* @param {string} str
|
|
57
57
|
* @return {string}
|
|
58
58
|
*/
|
|
59
|
-
exports.slug = function(str) {
|
|
59
|
+
exports.slug = function (str) {
|
|
60
60
|
return str
|
|
61
61
|
.toLowerCase()
|
|
62
62
|
.replace(/\s+/g, '-')
|
|
@@ -70,7 +70,7 @@ exports.slug = function(str) {
|
|
|
70
70
|
* @param {string} str
|
|
71
71
|
* @return {string}
|
|
72
72
|
*/
|
|
73
|
-
exports.clean = function(str) {
|
|
73
|
+
exports.clean = function (str) {
|
|
74
74
|
str = str
|
|
75
75
|
.replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
|
|
76
76
|
.replace(/^\uFEFF/, '')
|
|
@@ -212,7 +212,7 @@ exports.type = function type(value) {
|
|
|
212
212
|
* @param {*} value
|
|
213
213
|
* @return {string}
|
|
214
214
|
*/
|
|
215
|
-
exports.stringify = function(value) {
|
|
215
|
+
exports.stringify = function (value) {
|
|
216
216
|
var typeHint = canonicalType(value);
|
|
217
217
|
|
|
218
218
|
if (!~['object', 'array', 'function'].indexOf(typeHint)) {
|
|
@@ -228,7 +228,7 @@ exports.stringify = function(value) {
|
|
|
228
228
|
// IE7/IE8 has a bizarre String constructor; needs to be coerced
|
|
229
229
|
// into an array and back to obj.
|
|
230
230
|
if (typeHint === 'string' && typeof value === 'object') {
|
|
231
|
-
value = value.split('').reduce(function(acc, char, idx) {
|
|
231
|
+
value = value.split('').reduce(function (acc, char, idx) {
|
|
232
232
|
acc[idx] = char;
|
|
233
233
|
return acc;
|
|
234
234
|
}, {});
|
|
@@ -383,8 +383,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) {
|
|
|
383
383
|
canonicalizedObj = value;
|
|
384
384
|
break;
|
|
385
385
|
case 'array':
|
|
386
|
-
withStack(value, function() {
|
|
387
|
-
canonicalizedObj = value.map(function(item) {
|
|
386
|
+
withStack(value, function () {
|
|
387
|
+
canonicalizedObj = value.map(function (item) {
|
|
388
388
|
return exports.canonicalize(item, stack);
|
|
389
389
|
});
|
|
390
390
|
});
|
|
@@ -403,10 +403,10 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) {
|
|
|
403
403
|
/* falls through */
|
|
404
404
|
case 'object':
|
|
405
405
|
canonicalizedObj = canonicalizedObj || {};
|
|
406
|
-
withStack(value, function() {
|
|
406
|
+
withStack(value, function () {
|
|
407
407
|
Object.keys(value)
|
|
408
408
|
.sort()
|
|
409
|
-
.forEach(function(key) {
|
|
409
|
+
.forEach(function (key) {
|
|
410
410
|
canonicalizedObj[key] = exports.canonicalize(value[key], stack);
|
|
411
411
|
});
|
|
412
412
|
});
|
|
@@ -434,7 +434,7 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) {
|
|
|
434
434
|
* (i.e: strip Mocha and internal node functions from stack trace).
|
|
435
435
|
* @returns {Function}
|
|
436
436
|
*/
|
|
437
|
-
exports.stackTraceFilter = function() {
|
|
437
|
+
exports.stackTraceFilter = function () {
|
|
438
438
|
// TODO: Replace with `process.browser`
|
|
439
439
|
var is = typeof document === 'undefined' ? {node: true} : {browser: true};
|
|
440
440
|
var slash = path.sep;
|
|
@@ -442,9 +442,8 @@ exports.stackTraceFilter = function() {
|
|
|
442
442
|
if (is.node) {
|
|
443
443
|
cwd = exports.cwd() + slash;
|
|
444
444
|
} else {
|
|
445
|
-
cwd = (
|
|
446
|
-
? window.location
|
|
447
|
-
: location
|
|
445
|
+
cwd = (
|
|
446
|
+
typeof location === 'undefined' ? window.location : location
|
|
448
447
|
).href.replace(/\/[^/]*$/, '/');
|
|
449
448
|
slash = '/';
|
|
450
449
|
}
|
|
@@ -468,10 +467,10 @@ exports.stackTraceFilter = function() {
|
|
|
468
467
|
);
|
|
469
468
|
}
|
|
470
469
|
|
|
471
|
-
return function(stack) {
|
|
470
|
+
return function (stack) {
|
|
472
471
|
stack = stack.split('\n');
|
|
473
472
|
|
|
474
|
-
stack = stack.reduce(function(list, line) {
|
|
473
|
+
stack = stack.reduce(function (list, line) {
|
|
475
474
|
if (isMochaInternal(line)) {
|
|
476
475
|
return list;
|
|
477
476
|
}
|
|
@@ -522,7 +521,7 @@ exports.clamp = function clamp(value, range) {
|
|
|
522
521
|
* It's a noop.
|
|
523
522
|
* @public
|
|
524
523
|
*/
|
|
525
|
-
exports.noop = function() {};
|
|
524
|
+
exports.noop = function () {};
|
|
526
525
|
|
|
527
526
|
/**
|
|
528
527
|
* Creates a map-like object.
|
|
@@ -539,7 +538,7 @@ exports.noop = function() {};
|
|
|
539
538
|
* @param {...*} [obj] - Arguments to `Object.assign()`.
|
|
540
539
|
* @returns {Object} An object with no prototype, having `...obj` properties
|
|
541
540
|
*/
|
|
542
|
-
exports.createMap = function(obj) {
|
|
541
|
+
exports.createMap = function (obj) {
|
|
543
542
|
return Object.assign.apply(
|
|
544
543
|
null,
|
|
545
544
|
[Object.create(null)].concat(Array.prototype.slice.call(arguments))
|
|
@@ -558,7 +557,7 @@ exports.createMap = function(obj) {
|
|
|
558
557
|
* @returns {Object} A frozen object with no prototype, having `...obj` properties
|
|
559
558
|
* @throws {TypeError} if argument is not a non-empty object.
|
|
560
559
|
*/
|
|
561
|
-
exports.defineConstants = function(obj) {
|
|
560
|
+
exports.defineConstants = function (obj) {
|
|
562
561
|
if (canonicalType(obj) !== 'object' || !Object.keys(obj).length) {
|
|
563
562
|
throw new TypeError('Invalid argument; expected a non-empty object');
|
|
564
563
|
}
|