Skip to content

Commit

Permalink
fix test/unit/hook.spec.js (#4288)
Browse files Browse the repository at this point in the history
* fix test/unit/hook.spec.js

`Function.prototype.name` is not available in IE11, and will cause the browser tests to fail.

* another IE11 fix: avoid Array.prototype.findIndex

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
  • Loading branch information
boneskull committed May 14, 2020
1 parent 184036f commit 81e203c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions lib/runner.js
Expand Up @@ -192,15 +192,18 @@ Runner.prototype._addEventListener = function(target, eventName, listener) {
* @param fn {function}
*/
Runner.prototype._removeEventListener = function(target, eventName, listener) {
var eventListenerIndex = this._eventListeners.findIndex(function(
eventListenerDescriptor
) {
return (
var eventListenerIndex = -1;
for (var i = 0; i < this._eventListeners.length; i++) {
var eventListenerDescriptor = this._eventListeners[i];
if (
eventListenerDescriptor[0] === target &&
eventListenerDescriptor[1] === eventName &&
eventListenerDescriptor[2] === listener
);
});
) {
eventListenerIndex = i;
break;
}
}
if (eventListenerIndex !== -1) {
var removedListener = this._eventListeners.splice(eventListenerIndex, 1)[0];
removedListener[0].removeListener(removedListener[1], removedListener[2]);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/hook.spec.js
Expand Up @@ -4,7 +4,7 @@ var Mocha = require('../../lib/mocha');
var Hook = Mocha.Hook;
var Runnable = Mocha.Runnable;

describe(Hook.name, function() {
describe('Hook', function() {
var hook;

beforeEach(function() {
Expand Down

0 comments on commit 81e203c

Please sign in to comment.