mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
c9537e27f1
no issue - remove usages of function prototype extensions - fix usage of evented.off
32 lines
836 B
JavaScript
32 lines
836 B
JavaScript
import sinon from 'sinon';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {setupTest} from 'ember-mocha';
|
|
|
|
describe('Unit: Service: event-bus', function () {
|
|
setupTest();
|
|
|
|
it('works', function () {
|
|
let service = this.owner.lookup('service:event-bus');
|
|
let eventHandler = sinon.spy();
|
|
|
|
service.subscribe('test-event', this, eventHandler);
|
|
|
|
service.publish('test-event', 'test');
|
|
|
|
service.unsubscribe('test-event', this, 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;
|
|
});
|
|
});
|