Developing a callback-driven API, I would like to express that a certain function as to be called with a specific set of parameters and “any” function (the callback).
Jasmine can do the following:
var serviceFunction = jasmine.createSpy();
var functionUnderTest = create(serviceFunction);
var thing = 'arbitrary/thing'
functionUnderTest(thing);
expect(serviceFunction).toHaveBeenCalledWith(thing, jasmine.any(Function));
Have sinon/buster.js similar capabilities? So far I’m testing only the first argument, but I’d really like to express the need for a callback in the test.
This is what I have so far:
var serviceFunction = this.spy(); // or `sinon.spy()`
var functionUnderTest = create(serviceFunction);
var thing = 'arbitrary/thing'
functionUnderTest(thing);
assert.calledWith(serviceFunction, thing);