I'm trying to learn qunit test; I'm an OpenUi5 developer and I use Webstorm IDE every day. Webstorm allows me to config a Karma run configuration. I have created a simple karma configuration file and I have wrotten a test file test1.js
:
test("Test function sum()",
function() {
ok(sum(0, 0) == 0, "the sum of 0 with 0 is 0");
ok(sum(2, 0) == 2, "the sum of 2 with 0 is 2");
ok(sum(2, 1) == 3, "the sum of 2 with 1 is 3");
ok(sum(2, -1) == 1, "the sum of 2 with -1 is 1");
ok(sum(-2, 1) == -1, "the sum of -2 with 1 is -1");
});
function sum(a, b) {
return a + b;
};
Good! sum fnction in inside the same file. But now I want start to test function in my js
folder of projesct; for example in js/util.js
I have getShortIdGrid function:
//util.js file
ui5bp.control = {
...
getShortIdGrid: function(sFromId) {
if (sFromId.lastIndexOf("_") < 0)
return sFromId;
else
return sFromId.substring(0, sFromId.lastIndexOf("_"));
},
...
}
How can I call ui5bp.controlgetShortIdGrid
in my test?
Karma console show me ReferenceError: ui5bp is not defined
Aucun commentaire:
Enregistrer un commentaire