【发布时间】:2014-09-11 07:11:34
【问题描述】:
我想检查我的 Marionette 组件(例如控制器)附加了哪些侦听器:
组件示例代码:
var MyController = Marionette.Controller.extend({
initialize: function () {
this.listenTo(OtherModule, "start", function () {
// something happens here
});
this.listenTo(OtherModule, "stop", function () {
// something happens here
});
})
});
var myController = new MyController();
单元测试示例代码:
describe("MyController", function () {
it("should have 2 listeners registered", function () {
// ?
});
});
我可以触发事件,看看我想使用的函数是否使用 jasmine 的 spyOn 方法执行,但我很好奇是否有直接在组件上可用的附加事件列表。
如何检查我的组件在听什么?
【问题讨论】:
标签: javascript unit-testing backbone.js jasmine marionette