Currently, I am experimenting with callback functions using sinon.js
handleLoginActions = function (callback) {
...
if (callback) {
callback()
}
..
}
var loginCallbackStub = stub();
handleLoginActions(loginCallbackStub);
expect(loginCallbackStub).to.have.been.calledOnce; //successfully executed
However, when attempting to test the scenario with an invalid callback function, I encounter this issue: null is not a spy or a call to a spy! (and it makes sense)
var loginCallbackStub = null;
handleLoginActions(loginCallbackStub);
expect(loginCallbackStub).to.not.have.been.called;
Any suggestions or insights on this matter?
Thank you