angularjs - $httpBackend mock responds with more than what I tell it to? -
i have jasmine test 1 of angular services fetches data server , makes publicly accessible. server returns json, array of objects [{...}, {...}, ...] . now tried writing test mocked out http backend: var mocklibrary = [{}, {}]; beforeeach(inject(function(librarysvc) { libsvc = librarysvc; })); it('should fetch library', function(done) { inject(function($httpbackend) { $httpbackend.expectget('/library').respond(200, mocklibrary); libsvc.getlibrary() .then(function(response) { expect(_.isequal(response, mocklibrary)).tobetruthy(); }) .finally(done); $httpbackend.flush(); }); }); the code in service follows: var library; var deferred = $q.defer(); $http.get('/library') .then(function(data) { library = data; deferred.resolve(library); }, function(err) { deferred.reject(err); }); so, service assigns json response body of server in...