Testing Jsonp $resource Angularjs
How do I test a request being sent and data is being received with a JSONP service? angular.module('search', []) .factory('SearchService', function($q,$rootScope,$resource) {
Solution 1:
Try to call your search
like the following:
svc.user({user:'gigablox'}).search(function(user) {
expect(user.testing).toEqual('anything');
});
The reason is the call to svc.user()
returns a resource class object with a search()
method. The search()
method uses jsonp to make request. Without calling the search()
method, $httpBackend will not see any request, so you see the errors mentioned in your question.
Post a Comment for "Testing Jsonp $resource Angularjs"