title: Jasmine - How to spy on a function call within a function?
body: <p>The following is in my controller:</p>
  
  <pre><code>$scope.addRangesAndSquare = function() {
      $scope.addLeftRange();
      $scope.addCenterSquare();
      $scope.addRightRange();
  }
  </code></pre>
  
  <p>And I want to spy on <code>$scope.addLeftRange()</code>, so that when <code>$scope.addRangesAndSquare</code> is called so is <code>$scope.addLeftRange()</code>:</p>
  
  <pre><code>it('expect addLeftRange to be called after calling addRangesAndSquare', function () {
      spyOn(scope ,'addRangesAndSquare');
      spyOn(scope, 'addLeftRange');
      scope.addRangesAndSquare();
      expect(scope.addLeftRange).toHaveBeenCalled();
  });
  </code></pre>
  
  <p>How can this be done?</p>