FIX: prevents appEvents to leak (#7714)

This commit is contained in:
Joffrey JAFFEUX
2019-06-06 12:33:52 +02:00
committed by GitHub
parent 84e5d58a0d
commit c462c2f271
8 changed files with 129 additions and 80 deletions

View File

@ -154,6 +154,18 @@ QUnit.testDone(function() {
flushMap();
server.shutdown();
// ensures any event not removed is not leaking between tests
// most like in intialisers, other places (controller, component...)
// should be fixed in code
var appEvents = window.Discourse.__container__.lookup("app-events:main");
var events = appEvents.__proto__._events;
Object.keys(events).forEach(function(eventKey) {
var event = events[eventKey];
event.forEach(function(listener) {
appEvents.off(eventKey, listener.target, listener.fn);
});
});
});
// Load ES6 tests