title: How can I test for equality to a bound function when unit testing?
body: <p>I want to test that an argument passed to a function is a function reference but the function reference is being passed using <code>bind()</code>.</p>
  
  <p>Consider this code which is to be tested (shortened for brevity):</p>
  
  <pre><code>initialize: function () {
      this.register(this.handler.bind(this));
  }
  </code></pre>
  
  <p>And this unit test to check if <code>register()</code> was called with <code>handler()</code>:</p>
  
  <pre><code>it('register handler', function () {
      spyOn(bar, 'register');
      bar.initialize();
      expect(bar.register.calls.argsFor(0)[0]).toEqual(bar.handler);
  });
  </code></pre>
  
  <p>The arg doesn't equal the function reference I guess due to the bound function using <code>bind()</code> - how can I test that the correct function reference is being passed while still using the <code>bind()</code> method on it?</p>
  
  <p>Note: This isn't specific to jasmine, I just thought it was appropriate because of the methods being used.</p>