0
驗證機制的JsMockito不適合我。我的設置是我有2個類,通用和建議。JsMockito驗證機制不起作用
MyNS.Common = function() {};
MyNS.Suggestions = function() {};
我在建議中設置了Common的一個實例。
MyNS.Suggestions.prototype.setCommon = function(common) {this.common = common;};
然後我使用Common.getAdGroupId()的返回值並使用此值調用Suggestions.refresh()。這就是我想要測試的。
MyNS.Suggestions.prototype.init = function() {
// This is mocked to return 56 as can be seen in the test above.
var adGroupId = this.common.getAdGroupId();
this.refresh(adGroupId);
};
整個工作示例在小提琴上:http://jsfiddle.net/sbel/kqdTV/2/。請指教。