angularjs - Testing local methods containing service calls using Jasmine -


i facing issue testing local method in angular js controller.

i need test retrieveruledetails method contains service call, not able proceed. please test below code:

var retrieveruledetails = function(feeid, ruleid) {     $rootscope.triggerloading(true);     feesrulesservice.getrule(feeid, ruleid)         .then(getrulesuccess)         .catch(getrulefail); }; 

i think best pass feesrulesservice paramter - spy in jasmine , test getrule invoked

 feesrulesservicemock= {       getrule: function(feeid,ruleid) {        }     };      spyon(feesrulesservicemock, 'getrule');  retrieveruledetails(feeid,ruleid,feesrulesservicemock)  it("bla bla",function(){ expect(feesrulesservicemock.getrule).tohavebeencalled();   expect(feesrulesservicemock.getrule).tohavebeencalledwith(feeid,ruleid);  }); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -