Simple async spy helper
var spyThen = require('spy-then')(optionalOptions)
var makeSpy = spyThen(function() {
console.log('ready')
}, optionalOptions)
spyA = makeSpy('foo')
spyB = makeSpy('bar')
spyB('foo') // -> nothing happens
spyB('bar') // -> console.log('ready') will be called
You can either initialize the library with options or you can give them to each spy-maker individually.
Possible options are
-
options.argCheck
: should be a function that gets two arguments, first one is the expected argument, second one is the actual. You can feed those to your assertions library -
options.allowMultipleCalls
: should be true, if multiple calls of a spy are allowed
spyA = makeSpy({
args: ['argOffirstCall', 'arfOfSecondCall'],
minCallCount: 2,
maxCallCount: 4
})
minCallCount
maxCallCount