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

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -