I want to test following function.
var myFun = function (a, b, callback) {
async.map(a, function (b, mapCallback) {
//Do something with b => code I don't want to execute
mapCallback(null, res)
},
function (err, output) {
if (err) {
Logger.error(err);
return callback(err, null);
}
return callback(null, output.filter(function(n){ return n != null }));
});
}
Here I am using async.map, what I want is to stub. async.map
takes 3 parameters, first array and second and third callback. I want to stub second callback as well and call third callback with test values. How to do it?
I tried:
var mockAsync = sinon.stub(async, "map")
mockAsync.yields("Some error", null);
But this executes second function and not third function, I tried using callsArg
, but that also did not help, not sure that is relevant here or not.
Aucun commentaire:
Enregistrer un commentaire