title: How do you test for values created in a new Buffer in unit tests
body: <p>Let's say we have some code that does this:</p>
  
  <pre><code>callFunction(new Buffer(foo));
  </code></pre>
  
  <p>And we want to unit test this call with a sinon.js spy:</p>
  
  <pre><code>var spy = sinon.spy(callFunction);
  expect(spy.to.have.been.calledWith(foo));
  </code></pre>
  
  <p>This will fail because <code>callFunction</code> was called with <code>new Buffer(foo)</code> and not <code>foo</code>. The tests pass if we do <code>expect(spy.to.have.been.calledWith(new Buffer(foo))</code> but is it wise to keep creating new buffers for every test? Is there a better way to do this?</p>