When I called the mocking data in service the promises working for resolve. But i called the service in controller it is not calling the success call back.
code:
Service:
getHistory: function(deviceId,historyDataCount){
var deferred = $q.defer();
$http.get(historyDataCall+deviceId+"/"+historyDataCount).then(function successCallback(response){
return deferred.resolve(response.data);
}, function errorCallback (response) {
deferred.reject(response);
return response;
});
return deferred.promise;
},
Unit test:
service.getMachine(machineId);
service.getHistory(deviceObj.deviceId,5);
httpBackend.expect('GET', '/v1/machine/22')
.respond(200,mock_SingleMachine);
httpBackend.expect('GET', '/v1/devices/history/19442/5')
.respond(200,mock_Machine_History);
httpBackend.flush();
scope.History();
Controller: $scope.History() { var deffered = $q.defer(); backendServices.getHistory(deviceId, historyDataCount).then(function successCallback(response) { console.log(response); }
}
Here Not getting the scuccessCallback to check the response.
Aucun commentaire:
Enregistrer un commentaire