The function in which I am tracking takes an object as an argument. I need to claim that the function was called with certain properties of the object.
for example: my SUT has:
function kaboom() { fn({ foo: 'foo', bar: 'bar', zap: function() { ... }, dap: true }); }
and in my test I can do this:
fnStub = sinon.stub(); kaboom(); expect(fnStub).to.have.been.called;
and it works (it's good to know that fn was called). Now I need to make sure that the correct object has been passed to the function. I only care about the foo and bar properties, i.e. I need to match for specific properties of the argument. How?
upd: sinon.match () seems to work for simple objects. Let the bar rise, right?
What if I want to include the zap function in a statement? How to do it?
javascript unit-testing sinon sinon-chai
Agzam
source share