Skip to content

Commit

Permalink
Ensure resetActions() does not remove built-ins (d'oh!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr0grog committed Aug 3, 2016
1 parent 970f2f0 commit 15a183e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1916,17 +1916,24 @@ function withDeprecationTracking(constructor) {
*/
var _action = Nightmare.action;
var _pluginNames = [];
var _existingNamespaces = Nightmare.namespaces.slice();
var _existingChildActions = Object.assign({}, Nightmare.childActions);
Nightmare.action = function (name) {
_pluginNames.push(name);
return _action.apply(this, arguments);
};
// NOTE: this is somewhat fragile since there's no public API for removing
// plugins. If you touch `Nightmare.action`, please be sure to update this.
Nightmare.resetActions = function () {
_pluginNames.splice(0, _pluginNames.length).forEach((name) => {
delete this.prototype[name];
});
this.namespaces.splice(0, this.namespaces.length);
this.namespaces.push.apply(this.namespaces, _existingNamespaces);
Object.keys(this.childActions).forEach((name) => {
delete this.childActions[name];
if (!_existingChildActions[name]) {
delete this.childActions[name];
}
});
};

Expand Down

0 comments on commit 15a183e

Please sign in to comment.