I have an Angular App and I want to create unit test cases for it using jasmine.
In my AngularJS app, I have a service as :
var canceler;
var myServices = angular.module('myServices', ['ngResource'])
myServices.factory('getData', ['$http', '$q', function($http, $q){
var canceler;
return {
setData: function(url, callback, error) {
canceler = $q.defer();
$http.post(url, {}, {timeout:canceler.promise}).success(callback).error(error);
},
abort: function(){ canceler.resolve();}
}
}]);
This service is being used by controller.
Now how can I provide a mock for this "getData" service to the injector I am using in controllerSpecs.js (for the unit testing using jasmine).
For the reference, the code of controllerSpecs.js is defined in Getting error while using Jasmine with AngularJS.