dimanche 4 janvier 2015

how to check error in qunit

I have a function in JavaScript that uses the q library:



validateOnSelection : function(model) {
this.context.service.doLofig(model).then(function(bResult) {
if (bResult) {
return true;
} else {
throw new Error(that.context.i18n.getText("i18n", "error"));
}
});
}


How can I check in qunit that the result is error? Let's assume that the result: bResult is false and Error should raise.


I tried:



test("Basic test ", {
// get the oTemplate and model

return oTemplate.validateOnSelection(model).then(function(bResult) {
// Now I need to check the error
});

}));


The problem that I didn't get to the check "// Now I need to check the error"


Aucun commentaire:

Enregistrer un commentaire