angularjs - How to spyOn chained method call to Restangular in Jasmine? -
i using jasmine write unit tests angularjs factory returns call restangular. take example,
function functobetested(params) { return restangular.all('/foo').getlist(params); }
it straightforward test whether or not all() being called on restangular. how can test whether getlist() gets called on returned restangular object after all() has returned?
at moment, have
beforeeach(function() { module('ui.router'); module('myservice'); module('restangular'); }); describe('functobetested', function() { beforeeach(function() { httpbackend.expectget('/foo').respond([]); }); it('should call on restangular', function() { spyon(restangular, 'all').and.callthrough(); functobetested({}); httpbackend.flush(); expect(restangular.all).tohavebeencalled(); }); });
if try follow same pattern , along lines of
expect(restangular.all.getlist).tohavebeencalled();
things stop working. not able find literature on this. appreciated.
Comments
Post a Comment