Skip to content

Commit

Permalink
Remove listing of EVENT_SUITE_ADD* events as deprecated (#4760)
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Oct 3, 2021
1 parent 0ea732c commit 5d65912
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 47 deletions.
46 changes: 9 additions & 37 deletions lib/suite.js
Expand Up @@ -10,7 +10,6 @@ var {
assignNewMochaID,
clamp,
constants: utilsConstants,
createMap,
defineConstants,
getMochaID,
inherits,
Expand Down Expand Up @@ -92,16 +91,6 @@ function Suite(title, parentContext, isRoot) {
});

this.reset();

this.on('newListener', function(event) {
if (deprecatedEvents[event]) {
errors.deprecate(
'Event "' +
event +
'" is deprecated. Please let the Mocha team know about your use case: https://git.io/v6Lwm'
);
}
});
}

/**
Expand Down Expand Up @@ -647,49 +636,32 @@ var constants = defineConstants(
*/
HOOK_TYPE_BEFORE_EACH: 'beforeEach',

// the following events are all deprecated
/**
* Emitted after a child `Suite` has been added to a `Suite`.
*/
EVENT_SUITE_ADD_SUITE: 'suite',

/**
* Emitted after an "after all" `Hook` has been added to a `Suite`. Deprecated
* Emitted after an "after all" `Hook` has been added to a `Suite`
*/
EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll',
/**
* Emitted after an "after each" `Hook` has been added to a `Suite` Deprecated
* Emitted after an "after each" `Hook` has been added to a `Suite`
*/
EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach',
/**
* Emitted after an "before all" `Hook` has been added to a `Suite` Deprecated
* Emitted after an "before all" `Hook` has been added to a `Suite`
*/
EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll',
/**
* Emitted after an "before each" `Hook` has been added to a `Suite` Deprecated
* Emitted after an "before each" `Hook` has been added to a `Suite`
*/
EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach',
/**
* Emitted after a child `Suite` has been added to a `Suite`. Deprecated
*/
EVENT_SUITE_ADD_SUITE: 'suite',
/**
* Emitted after a `Test` has been added to a `Suite`. Deprecated
* Emitted after a `Test` has been added to a `Suite`.
*/
EVENT_SUITE_ADD_TEST: 'test'
}
);

/**
* @summary There are no known use cases for these events.
* @desc This is a `Set`-like object having all keys being the constant's string value and the value being `true`.
* @todo Remove eventually
* @type {Object<string,boolean>}
* @ignore
*/
var deprecatedEvents = Object.keys(constants)
.filter(function(constant) {
return constant.substring(0, 15) === 'EVENT_SUITE_ADD';
})
.reduce(function(acc, constant) {
acc[constants[constant]] = true;
return acc;
}, createMap());

Suite.constants = constants;
10 changes: 0 additions & 10 deletions test/unit/suite.spec.js
Expand Up @@ -548,16 +548,6 @@ describe('Suite', function() {
new Suite('Bdd suite', 'root');
}, 'not to throw');
});

it('should report listened-for deprecated events as deprecated', function() {
new Suite('foo').on(
Suite.constants.EVENT_SUITE_ADD_TEST,
function() {}
);
expect(errors.deprecate, 'to have a call satisfying', [
/Event "[^"]+" is deprecated/i
]);
});
});

describe('timeout()', function() {
Expand Down

0 comments on commit 5d65912

Please sign in to comment.