【发布时间】:2012-11-13 22:05:12
【问题描述】:
我在 Backbone 的 View 初始化方法中执行了一个方法。
initialize : function(options) {
this.myMethod();
}
我正在尝试使用 sinon 来窥探这种方法,例如:
this.spyMyMethod = sinon.spy(this.view, "myMethod");
然后结束
it('should call my method', function(){
expect(this.spyMyMethod).toHaveBeenCalledOnce();
});
但是测试失败了……
有什么想法吗?
【问题讨论】:
标签: backbone.js jasmine sinon