mercredi 4 février 2015

how do you test an if statement in javascript/angular js?

here is some code i have got:



$scope.changePassword = function () {
sessionService.save($scope.sessionData);
if(sessionService.account.newPassword == sessionService.account.currentPassword) {
return false;
}
webServiceDal.changePassword().success(function (response) {
if (response.ChangePasswordAppResponse.errorFlag)
$scope.globalError = response.ChangePasswordAppResponse.returnMsg;
else
$location.path('/my-preferences');
});
};


how would you write a unit test for this? do i need to mock something. im new to javascript/angular js unit testing and so need some guidance as to where to start. i have looked at the docs but they dont have examples for if else statements


Aucun commentaire:

Enregistrer un commentaire