开发者

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();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜