title: Function inside of for loop not being tested
body: <p>I have a function im trying to test:</p>
  
  <pre><code>  vm.clearArray = function(){
      for (var id=0; id&lt;vm.copyArray.length;id++){
        vm.styleIcon(vm.copyArray[id],'black')
      }
      vm.copyObjArray = [];
      vm.copyArray = [];
    }
  </code></pre>
  
  <p>I'm trying to test it like:</p>
  
  <pre><code>it('should have cleared copyArray on function call', function(){
  
      var ctrl = $componentController('copy', null);
  
      spyOn(ctrl, 'clearArray').and.callThrough();
      spyOn(ctrl, 'styleIcon').and.callThrough();
  
      ctrl.copyArray = [123];
      ctrl.clearArray();
  
      expect(ctrl.clearArray).toHaveBeenCalled();
      // expect(ctrl.styleIcon).toHaveBeenCalled();
      expect(ctrl.copyObjArray).toEqual([]);
      expect(ctrl.copyArray).toEqual([]);
    });
  </code></pre>
  
  <p>If I uncomment the above expect I get an error and the vm.styleIcon call is never covered in my coverage report.  By setting copyArray to contain a value in the array I would think that the for loop would then trigger when running the test.  That does not seem to be the case.</p>
  
  <p>Thanks.</p>