How to test private functions?

1

I have a controller with some functions:

angular.module('teste.controllers')
.controller(TestCtrl, function($scope){
   var vm = this;

   vm.funcTest = function(){
    return 1 + 1;
   }

   function _testSoma2(){
     return 2 + 2;
   }
})

Now on the test:

describe('Controllers: Timetable', function () {
 var TestCtrl;
 var $controller;
 var $scope;

 beforeEach(module('teste'));

 beforeEach(inject(function($controller, $injector){ 
   $controller = $controller;
   TestCtrl = $controller('TestCtrl', {
        '$scope': $scope
      });
   }));
   it('testar function privada.', function () {
      //como testar?
      //TestCtrl._testSoma2() ??
      expect(4).toBe(4);
   });
});

How can I perform the test in the function _testSoma2 ()?

I get $ scope.vm.funcTest () but in _testSoma2 () I can not.

I can call this private function for several other scope functions, but I want to test this function separately.

    
asked by anonymous 15.09.2015 / 16:46

0 answers