spy-then

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i spy-then

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • stephan.hoyer