我有一个这样的格式化程序文件
sap.ui.define([], function() {
"use strict";
return {
someFunction: function(sKey) {
var sResult = "";
var model = this.getModel("somekey");
if (model) {
var oItem = model.getProperty("/yesno")[parseInt(sKey) - 1];
if (oItem) {
sResult = oItem.Name;
}
}
return sResult;
}
};
});
,并且在这样的控制器onInit
函数中定义模型
this.setModel(new sap.ui.model.json.JSONModel(this._somekey), "somekey");
onInit: function() {
// object containing the model data for header dropdowns
this._somekey = {
//uses ResourceBundle here
............
...........
}
}
现在,我想在格式化程序中测试someFunction。我不知道该怎么做?
我尝试过
var oModel = this.stub();
oModel.withArgs("headerDropdowns").returns(/* donno what to return here */);
var oControllerStub = {
getModel: oModel
};
var fnIsolatedFormatter = formatter.someFunction.bind(oControllerStub);
assert.strictEqual(fnIsolatedFormatter.someFunction("1"), "dropdown string do not match");
});
答案 0 :(得分:1)
=IF([annual_roll_amount]=="N/A";"N/A";CONCATENATE("$";[annual_roll_amount]))