Created
May 15, 2014 15:57
-
-
Save Unitech/b8411abcad87a30fd548 to your computer and use it in GitHub Desktop.
Testing events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sinon = require('sinon') | |
, EventEmitter = require('events').EventEmitter; | |
describe('EventEmitter', function(){ | |
describe('#emit()', function(){ | |
it('should invoke the callback', function(){ | |
var spy = sinon.spy() | |
, emitter = new EventEmitter; | |
emitter.on('foo', spy); | |
emitter.emit('foo'); | |
spy.called.should.equal.true; | |
}) | |
it('should pass arguments to the callbacks', function(){ | |
var spy = sinon.spy() | |
, emitter = new EventEmitter; | |
emitter.on('foo', spy); | |
emitter.emit('foo', 'bar', 'baz'); | |
sinon.assert.calledOnce(spy); | |
sinon.assert.calledWith(spy, 'bar', 'baz'); | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment