title: jasmine.clock().tick() does not work with $timeout and debounce, but works fine with setTimeout
body: <p>Below I have 3 functions that do exactly the same thing. Each one uses a different way of calling <code>setTimeout</code>, <code>delay1()</code> uses <code>setTimeout</code> directly, <code>delay2()</code> uses angularjs <code>$timeout</code> and <code>delay3()</code> uses lodash <code>debounce</code>. They all work fine.</p>
  
  <p>The problems occurs when I test using Jasmine. <code>setTimeout</code> works fine with the <code>jasmine.clock().tick()</code> method, but <code>$timeout</code> and <code>debounce</code> don't</p>
  
  <p>I am interested in getting debounce working with Jasmine. I know I can use <code>$timeout.flush()</code> with angularjs but <code>$timeout</code> and <code>setTimeout</code> give me problems elsewhere in my code where I am using it with leaflet maps. debounce works nicely with leaflet.</p>
  
  <p>I have created a plunker here: <a href="http://plnkr.co/edit/BCGoTdnJ0mrMYVPljGhr?p=preview" rel="nofollow noreferrer">plnkr</a> where you will see the <code>$timeout</code> and debounce tests not passing while the setTimeout test passes.</p>
  
  <p>Is there a way I can work around this problem? Thanks</p>
  
  <p>JS</p>
  
  <pre><code>var app = angular.module('plunker', []);
  
  app.controller('MainCtrl', function($scope, $timeout) {
    $scope.name = 'World';
    $scope.delayed1 = function(){
      setTimeout(function(){
        $scope.name = "Hello world by setTimeout";
      },500)
    }
    $scope.delayed2 = function(){
      $timeout(function(){
        $scope.name = "Hello world by $timeout";
      },500)
    }
    $scope.delayed3 = function(){
      _.debounce(function(){
        $scope.name = "Hello world by debounce";
      },500)
    }
  });
  </code></pre>
  
  <p>spec</p>
  
  <pre><code>describe('Testing a Hello World controller', function() {
    var $scope = null;
    var ctrl = null;
  
    //you need to indicate your module in a test
    beforeEach(module('plunker'));
  
    beforeEach(inject(function($rootScope, $controller) {
      $scope = $rootScope.$new();
  
      ctrl = $controller('MainCtrl', {
        $scope: $scope
      });
    }));
  
    it('should say hallo to the World', function() {
      expect($scope.name).toEqual('World');
    });
    it('should say Hello world by setTimeout', function() {
      jasmine.clock().install();
      $scope.delayed1();
      jasmine.clock().tick(600);
      expect($scope.name).toEqual('Hello world by setTimeout');
      jasmine.clock().uninstall();
  
    });
    it('should say Hello world by timeout', function() {
      jasmine.clock().install();
      $scope.delayed2();
      jasmine.clock().tick(600);
      expect($scope.name).toEqual('Hello world by timeout');
      jasmine.clock().uninstall();
  
    }); 
    it('should say Hello world by debouce', function() {
      jasmine.clock().install();
      $scope.delayed3();
      jasmine.clock().tick(600);
      expect($scope.name).toEqual('Hello world by debouce');
      jasmine.clock().uninstall();
  
    }); 
  });
  </code></pre>