According to documentation of sinon.js, I can do like this: var spy = sinon.spy(myFunc);
, but it doesn't work. Here is my effort:
var sinon = require("sinon");
describe('check bar calling', function(){
it('should call bar once', function() {
var barSpy = sinon.spy(bar);
foo("aaa");
barSpy.restore();
sinon.assert.calledOnce(barSpy);
});
});
function foo(arg) {
console.log("Hello from foo " + arg);
bar(arg);
}
function bar(arg) {
console.log("Hellof from bar " + arg);
}
Aucun commentaire:
Enregistrer un commentaire