Skip to content

StephanHoyer/spy-then

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status rethink.js js-standard-style Dependency Status

spy-then

Simple async spy helper

Usage

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

Options

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

Todo/Ideas

Expect callCount

spyA = makeSpy({
  args: ['argOffirstCall', 'arfOfSecondCall'],
  minCallCount: 2,
  maxCallCount: 4
})

more options

  • minCallCount
  • maxCallCount

About

Simple async spy helper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published