[FIX] mail: tests: correctly destroy with createDiscuss helper
Before this commit, when using createDiscuss and performing discuss.destroy, the parent widget was not destroyed. This is an issue, because the mocked environment is attached to the parent widget of discuss. Any call to this.getSession() is mocked by the addMockEnvironment, and this mocked behaviour is removed only when the corresponding widget is destroyed. This commit overrides discuss.destroy(), so that the parent widget is also destroyed, so that it removes the side effect on this.getSession() from the mocked environment.
This commit is contained in:
@@ -77,6 +77,15 @@ function createDiscuss(params) {
|
||||
var selector = params.debug ? 'body' : '#qunit-fixture';
|
||||
discuss.appendTo($(selector));
|
||||
|
||||
// override 'destroy' of discuss so that it calls 'destroy' on the parent
|
||||
// instead, which is the parent of discuss and the mockServer.
|
||||
discuss.destroy = function () {
|
||||
// remove the override to properly destroy discuss and its children
|
||||
// when it will be called the second time (by its parent)
|
||||
delete discuss.destroy;
|
||||
parent.destroy();
|
||||
};
|
||||
|
||||
return discuss.call('chat_manager', 'isReady').then(function () {
|
||||
return discuss;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user