hoodwink

2.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i hoodwink

Weekly Downloads

288

Version

2.0.0

License

MIT

Unpacked Size

4.75 kB

Total Files

6

Last publish

Collaborators

  • dcousens