EventEmitter assertions for Unexpected
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.eslintrc.yml
.gitignore
.travis.yml
.wallaby.js
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

unexpected-eventemitter

EventEmitter assertions for Unexpected

Installation

Requires Node.js v6 or newer

$ npm i unexpected unexpected-eventemitter -D

Example

const unexpected = require('unexpected');
const uee = require('unexpected-eventemitter');
const {EventEmitter} = require('events');

const expect = unexpected.clone()
  .use(uee);

const ee = new EventEmitter();
expect(() => ee.emit('foo', {bar: 'baz'}), 'to emit from', ee, 'foo', {
  bar: 'baz'
});

Assertions

to emit from

<function> [not] to emit from <EventEmitter> <string> <any*>

  • EventEmitter may be a duck-typed Node.js EventEmitter.
  • <any*> corresponds to zero (0) or more values which may be emitted.
  • An EventEmitter emitting more values than expected will not fail an assertion.
  • Values are checked with "to satisfy" for flexibility.

License

©️ 2017 Christopher Hiller. Licensed Apache-2.0.