我正在尝试为此模块实现一个测试(1)。
我的目的是在触发特定事件时检查是否获取了集合。
正如您从(2)中的注释中所看到的,我收到了消息
该模块可以工作,但测试失败了。有什么想法吗?
(2)
我的目的是在触发特定事件时检查是否获取了集合。
正如您从(2)中的注释中所看到的,我收到了消息
Error: Expected a spy, but got Function.
该模块可以工作,但测试失败了。有什么想法吗?
// jasmine test module
describe('When onGivePoints is fired', function () {
beforeEach(function () {
spyOn(this.view.collection, 'restartPolling').andCallThrough();
app.vent.trigger('onGivePoints');
});
it('the board collection should be fetched', function () {
expect(this.view.collection.restartPolling).toHaveBeenCalled();
// Error: Expected a spy, but got Function.
});
});
(2)
// model view module
return Marionette.CompositeView.extend({
initialize: function () {
this.collection = new UserBoardCollection();
this.collection.startPolling();
app.vent.on('onGivePoints', this.collection.restartPolling);
},
// other code
});
期望 spy,但得到了 Function
。我更新了我的问题。 - Lorraine Bernard