2016-08-17 18:01:46 +03:00
|
|
|
/* jshint expr:true */
|
2016-11-14 16:16:51 +03:00
|
|
|
import {expect} from 'chai';
|
2016-08-17 18:01:46 +03:00
|
|
|
import {
|
|
|
|
describeModule,
|
|
|
|
it
|
|
|
|
} from 'ember-mocha';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
|
|
|
|
describeModule(
|
|
|
|
'service:event-bus',
|
|
|
|
'Unit: Service: event-bus',
|
|
|
|
{},
|
|
|
|
function() {
|
|
|
|
it('works', function () {
|
|
|
|
let service = this.subject();
|
|
|
|
let eventHandler = sinon.spy();
|
|
|
|
|
|
|
|
service.subscribe('test-event', eventHandler);
|
|
|
|
|
|
|
|
service.publish('test-event', 'test');
|
|
|
|
|
|
|
|
service.unsubscribe('test-event', eventHandler);
|
|
|
|
|
|
|
|
service.publish('test-event', 'test two');
|
|
|
|
|
|
|
|
expect(
|
|
|
|
eventHandler.calledOnce,
|
|
|
|
'event handler only triggered once'
|
|
|
|
).to.be.true;
|
|
|
|
|
|
|
|
expect(
|
|
|
|
eventHandler.calledWith('test'),
|
|
|
|
'event handler was passed correct arguments'
|
|
|
|
).to.be.true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|