The issue is at the time you assign a spy on triggerFilterEvent
, an event listener is already set to call the original function and not the spy (initialize
is called when you initialize the view)
To get around that you can spy on the prototype, before you initialize the view :
spyOn(TreeView.prototype, 'triggerFilterEvent');
var treeView = new TreeView();