Answer the question
In order to leave comments, you need to log in
Unit tests Angular, how to test a request to a provider?
Good day. I decided to deal with unit testing in Angular (and unit testing in general).
Testing the login form controller:
$scope.login = function(){
$auth.login({
user: $scope.user.name,
password: $scope.user.password
}).then(
function(resp){
console.log(resp);
$scope.resp = resp;
return $state.go('auth.dm');
},
function(){
console.error("cant't update ");
}
)
};
login: function (params) {
var _this = this;
_this.initDfd();
$http.post(configs.apiUrl, params)
.success(function (resp) {
_this.setAuthorized(resp);
return _this.resolveDfd();
})
.error(function () {
return _this.rejectDfd();
});
return _this.dfd.promise;
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question