unexpected-events
This unexpected plugin enables unit testing of EventEmitters.
Check a single event
To check an event is produced the 'for the first event on' assertion is provided - you specify the channel and the assertion to use when doing the match:
var EventEmitter = EventEmitter;var expect = ; expect; ;
In this case you can see an event on the channel foo with the values foo and bar being sent.
Two special forms of the assertion are provided in case you need to ignore a certain number of messages before doing the comparisons:
-
check the second event (i.e. skip one event)
; -
check the third event (i.e. skip two events)
;
Readability
For ease of readability you can also remove the array around the event values by brandishing the optional values flag in the assertion:
var EventEmitter = EventEmitter;var expect = ; ;
You'll also notice, as in the example above, you can drop the word first when comparing a single event.
For your convenience you understand.
Check multiple events
If you want to check a series of messages on a channel, there is an assertion for you too!
var EventEmitter = EventEmitter;var expect = ; expect; ;
License
Licensed under a standard 3-clause BSD license -- see the LICENSE
file for details.