title: How to test a function which has a setTimeout with jasmine?
body: <p>I need to write a test for a function that has a <code>setTimeout()</code> call inside, but i can't find how i should do.</p>
  
  <p>This is the function</p>
  
  <pre><code>// Disables all submit buttons after a submit button is pressed.
  var block_all_submit_and_ajax = function( el ) {
      // Clone the clicked button, we need to know what button has been clicked so that we can react accordingly
      var $clone = $( el ).clone();
      // Change the type to hidden
      $clone.attr( 'type', 'hidden' );
      // Put the hidden button in the DOM
      $( el ).after( $clone );
      // Disable all submit button. I use setTimeout otherwise this doesn't work in chrome.
      setTimeout(function() {
           $( '#facebook input[type=submit]' ).prop( 'disabled', true );
       }, 10);
      // unbind all click handler from ajax
      $( '#facebook a.btn' ).unbind( "click" );
      // Disable all AJAX buttons.
      $( '#facebook a.btn' ).click( function( e ) {
          e.preventDefault();
          e.stopImmediatePropagation();
      } );
  };
  </code></pre>
  
  <p>And this is my test</p>
  
  <pre><code>it( "Disable all submit buttons", function() {
      // Get a button
      var $button = $( '#ai1ec_subscribe_users' );
      // Call the function
      utility_functions.block_all_submit_and_ajax( $button.get(0) );
      // check that all submit are disabled
      $( '#facebook input[type=submit]' ).each( function( i, el ) {
          console.log( 'f' );
          expect( el ).toHaveProp( 'disabled', true );
      } );
  } );
  </code></pre>
  
  <p>I've tried using <code>jasmine.Clock.useMock();</code> and <code>jasmine.Clock.tick(11);</code> but i couldn't get things to work, the test never pass</p>