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
Post a Comment