unit testing - How to test self. angularjs controller functions in jasmine -


i have below code inside controller

controller:

self.dosomething = function () {     self.x="hai";     self.y = function (id, data) {         self.x="hello";     } }  $scope.call=function(){     self.dosomething(); } 

there no other self.y function defined other given code.

whenever test call function through jasmine calling it. code coverage not showing inside self.y function. i.e., self.x="hello" not being called. please suggest me way how this.

thanks in advance.

self.y property of self. way call is first define calling $scope.call() call self.y

$scope.call(); self.y(); 

unless exposing self controller. code in self.y not testable. if want execute when call dosomething must explicitly.

self.dosomething = function () {     self.x="hai";     self.y = function (id, data) {         self.x="hello";     }     self.y(); } 

but why writing code this?


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -