Ghost/ghost/admin/tests/unit/services/event-bus-test.js
Kevin Ansfield 1520122483 Refactored deprecated usage of setupTest* methods
no issue

- https://github.com/emberjs/ember-mocha/blob/master/docs/migration.md#upgrading-to-the-new-testing-apis
- deleted tests files which had no specific tests
- migrated unskipped component unit tests to integration tests
2019-05-13 15:31:32 +01:00

32 lines
824 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', 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;
});
});