验证JsMockito的机制不适合我。我的设置是我有两个类,公共和建议。
MyNS.Common = function() {};
MyNS.Suggestions = function() {};我在建议中列举了一个共同的例子。
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/。请给我建议。
发布于 2013-03-05 00:43:45
你这里有几个错误。
希望这能有所帮助!
https://stackoverflow.com/questions/14983767
复制相似问题