【问题标题】:Testing backbone event-hash测试主干事件哈希
【发布时间】:2015-03-30 16:37:50
【问题描述】:

我需要在 Backbone 的 event-hash 中应用一个“特殊”函数调用,其中同一个事件侦听器在我的 Backbone 视图中触发两个独立的方法。但是,当检查我的代码覆盖率时,这个特定的 sn-p 代码是未经测试的。

我正在使用mochachaisinonjs

我想知道是否有人知道如何测试这种特殊情况?

events: {
        "focus #new-comment": function (e) {
            this.revealButtons(e);
            this._cancelZoom(e);
        },
}

【问题讨论】:

    标签: javascript events backbone.js mocha.js


    【解决方案1】:

    这有帮助吗?

    events: {
        "focus #new-comment": "_onFocusNewComment",
    },
    
    _onFocusNewComment: function (e) {
        this.revealButtons(e);
        this._cancelZoom(e);
    }
    

    【讨论】:

    • 很好,简单的答案!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 2011-10-01
    • 2013-02-13
    相关资源
    最近更新 更多