Skip to content

Commit 111467f

Browse files
authoredOct 3, 2021
fix(integration): revert deprecation of 'EVENT_SUITE_ADD_*' events (#4764)
1 parent 0ea732c commit 111467f

File tree

2 files changed

+15
-54
lines changed

2 files changed

+15
-54
lines changed
 

‎lib/suite.js

+15-44
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var {
1010
assignNewMochaID,
1111
clamp,
1212
constants: utilsConstants,
13-
createMap,
1413
defineConstants,
1514
getMochaID,
1615
inherits,
@@ -92,16 +91,6 @@ function Suite(title, parentContext, isRoot) {
9291
});
9392

9493
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-
});
10594
}
10695

10796
/**
@@ -614,7 +603,7 @@ var constants = defineConstants(
614603
*/
615604
{
616605
/**
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.
618607
*/
619608
EVENT_FILE_POST_REQUIRE: 'post-require',
620609
/**
@@ -626,70 +615,52 @@ var constants = defineConstants(
626615
*/
627616
EVENT_FILE_REQUIRE: 'require',
628617
/**
629-
* Event emitted when `global.run()` is called (use with `delay` option)
618+
* Event emitted when `global.run()` is called (use with `delay` option).
630619
*/
631620
EVENT_ROOT_SUITE_RUN: 'run',
632621

633622
/**
634-
* Namespace for collection of a `Suite`'s "after all" hooks
623+
* Namespace for collection of a `Suite`'s "after all" hooks.
635624
*/
636625
HOOK_TYPE_AFTER_ALL: 'afterAll',
637626
/**
638-
* Namespace for collection of a `Suite`'s "after each" hooks
627+
* Namespace for collection of a `Suite`'s "after each" hooks.
639628
*/
640629
HOOK_TYPE_AFTER_EACH: 'afterEach',
641630
/**
642-
* Namespace for collection of a `Suite`'s "before all" hooks
631+
* Namespace for collection of a `Suite`'s "before all" hooks.
643632
*/
644633
HOOK_TYPE_BEFORE_ALL: 'beforeAll',
645634
/**
646-
* Namespace for collection of a `Suite`'s "before all" hooks
635+
* Namespace for collection of a `Suite`'s "before each" hooks.
647636
*/
648637
HOOK_TYPE_BEFORE_EACH: 'beforeEach',
649638

650-
// the following events are all deprecated
651-
652639
/**
653-
* Emitted after an "after all" `Hook` has been added to a `Suite`. Deprecated
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`.
654645
*/
655646
EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll',
656647
/**
657-
* Emitted after an "after each" `Hook` has been added to a `Suite` Deprecated
648+
* Emitted after an "after each" `Hook` has been added to a `Suite`.
658649
*/
659650
EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach',
660651
/**
661-
* Emitted after an "before all" `Hook` has been added to a `Suite` Deprecated
652+
* Emitted after an "before all" `Hook` has been added to a `Suite`.
662653
*/
663654
EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll',
664655
/**
665-
* Emitted after an "before each" `Hook` has been added to a `Suite` Deprecated
656+
* Emitted after an "before each" `Hook` has been added to a `Suite`.
666657
*/
667658
EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach',
668659
/**
669-
* Emitted after a child `Suite` has been added to a `Suite`. Deprecated
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`.
674661
*/
675662
EVENT_SUITE_ADD_TEST: 'test'
676663
}
677664
);
678665

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-
695666
Suite.constants = constants;

‎test/unit/suite.spec.js

-10
Original file line numberDiff line numberDiff line change
@@ -548,16 +548,6 @@ describe('Suite', function() {
548548
new Suite('Bdd suite', 'root');
549549
}, 'not to throw');
550550
});
551-
552-
it('should report listened-for deprecated events as deprecated', function() {
553-
new Suite('foo').on(
554-
Suite.constants.EVENT_SUITE_ADD_TEST,
555-
function() {}
556-
);
557-
expect(errors.deprecate, 'to have a call satisfying', [
558-
/Event "[^"]+" is deprecated/i
559-
]);
560-
});
561551
});
562552

563553
describe('timeout()', function() {

0 commit comments

Comments
 (0)
Please sign in to comment.