Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/unit/specs/factories/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,41 @@ define(function (require) {
});
});

it('should pass multiple arguments from the emitter', function () {
var obj = new Events();
var handler = sinon.stub();
var payload = [
'one',
{ hello: 'tests' },
null
];

obj.on('test', handler);

return obj.emit('test', payload[0], payload[1], payload[2])
.then(function () {
expect(handler.callCount).to.be(1);
expect(handler.calledWithExactly(payload[0], payload[1], payload[2])).to.be(true);
});
});

it('should preserve the scope of the handler', function () {
var obj = new Events();
var expected = 'some value';
var testValue;

function handler(arg1, arg2) {
testValue = this.getVal();
}
handler.getVal = _.constant(expected);

obj.on('test', handler);
return obj.emit('test')
.then(function () {
expect(testValue).to.equal(expected);
});
});

it('should always emit in the same order', function () {
var handler = sinon.stub();

Expand Down