【发布时间】:2016-04-30 06:20:03
【问题描述】:
我不知道为什么我的测试不起作用。
it('should be called when "get-tentative-events" is fired', function() {
spyOn(this.VM, 'addEvents');
spyOn(this.VM, 'setEventData').and.returnValue(null);
this.VM.$root.$broadcast('get-tentative-events', []);
expect(this.VM.addEvents).toBeDefined();
expect(this.VM.addEvents).toHaveBeenCalled();
});
在调试中,我确认addEvents被调用了。
但是出现了错误single-calendar addEvents should be called when "get-tentative-events" is fired FAILED
仅供参考:
如果我改变了
this.VM.$root.$broadcast('get-tentative-events', []);
到
this.VM.addEvents([])
我可以通过这个测试。所以我不明白为什么我的测试失败了。
【问题讨论】:
标签: javascript unit-testing jasmine vue.js