spy on jquery ui widget in jasmine
I have a jquery ui widget defined like this:
$.widget("ui.someWidget",
options: {},开发者_如何学编程 _create = function() { doSomething();
});
Now i tried to spy on it like that:
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?
Your expectation needs to reference a method on the spy:
expect(ui_spy.someWidget).toHaveBeenCalled();
精彩评论