Spy on jquery ui widget in jasmine

I have a jquery ui widget defined as follows:

$.widget("ui.someWidget", options: {}, _create = function() { doSomething(); }); 

Now I tried to spy like this:

 var ui_spy = spyOn($.fn, "someWidget"); $('#something').someWidget(); expect(ui_spy).toHaveBeenCalled(); var ui_spy = spyOn($.ui, "someWidget"); $('#something').someWidget(); expect(ui_spy).toHaveBeenCalled(); 

Both return false ... what am I doing wrong?

+4
source share
1 answer

Your expectation should refer to the spy method:

expect(ui_spy.someWidget).toHaveBeenCalled();

+4
source

All Articles