【发布时间】:2018-06-23 03:59:08
【问题描述】:
我有类 SomeClass 方法 SomeClass.fetch()
var repository = {
get: function(obj) {
//...
}
};
var cache = false;
var SomeClass = {
init: function() {
//...
},
fetch: function () {
var _this = this;
repository.get({
method: 'getRecentDialogsList',
success: function (result) {
if (!cache) {
_this.set(result);
_this.sort();
_this.trigger('fetch:success', _this);
}
_this.trigger('fetch:ajaxSuccess', _this);
}
});
}
}
我如何测试 SomeClass.fetch() 并检查是否已通过参数调用 this.set()、this.sort、this.trigger?
【问题讨论】:
标签: javascript unit-testing jasmine