Last active
February 28, 2019 09:10
-
-
Save fatso83/ba6151072c3db5748e3bf7c63bb3b84d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sinon = require('sinon'); | |
const stub = sinon.stub(); | |
const spy = sinon.spy(function(){}); | |
function test(spy){ | |
spy(1,2,3,4); | |
spy(1,2); | |
spy(1,2); | |
spy(1); | |
console.log(spy.calledWith(1,2,3,4)); | |
console.log(spy.withArgs(1,2,3,4).calledOnce); | |
console.log(spy.withArgs(1,2,3,4).callCount === 1); | |
console.log(spy.calledWith(1,2)); | |
console.log(spy.withArgs(1,2).calledOnce === false); | |
console.log(spy.withArgs(1,2).callCount === 3); | |
// missing | |
// console.log(spy.calledWithExactly(1,2)); | |
// console.log(spy.calledWithExactly(1,2).calledOnce); | |
} | |
test(spy); | |
test(stub); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment