mercredi 18 février 2015

SinonJS stub for an async function with one argument and multiple callback values

I have an async function call like this:



db.findUser(username, function (err, user) {

});


I have tried to create the stub like this:



dbMock.findUser = sinon.stub().callsArg(1, "mockUsername", {"err":null, "user":mockFindUserResponse});


Also I tried with callsArgWith:



dbMock.findUser = sinon.stub().callsArgWith(1, "mockUsername", null, mockFindUserResponse);


But no luck.


Sinon seems to ignore the second callback value.


Aucun commentaire:

Enregistrer un commentaire