2.0.0 • Published 6 years ago

hoodwink v2.0.0

Weekly downloads
57
License
MIT
Repository
github
Last release
6 years ago

hoodwink

build status Version

A dead simple mock/stub module for Javascript

TODO: hoodwink/async

Examples

const tape = require('tape')
const hoodwink = require('hoodwink')

tape('stub returns 0, then 1', hoodwink(function (t) {
  const foo = this.stub(function f () {
    if (foo.calls === 0) return 0
    if (foo.calls === 1) return 1
  }, 2)

  t.equal(foo(), 0)
  t.equal(foo(), 1)
  // t.equal(foo(), ...) // XXX: throws! (as foo.calls would be > 2)
})

Protip: use function (...) {}, not () => {}, to prevent this binding issues

License MIT