mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
983110d931
no issue - add eslint-plugin-ember, configure no-old-shims rule - run `eslint --fix` on `app`, `lib`, `mirage`, and `tests` to move imports to the new module imports - further cleanup of Ember globals usage - remove event-dispatcher initializer now that `canDispatchToEventManager` is deprecated
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
/* jshint expr:true */
|
|
import Service from '@ember/service';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import {describe, it} from 'mocha';
|
|
import {A as emberA} from '@ember/array';
|
|
import {expect} from 'chai';
|
|
import {setupComponentTest} from 'ember-mocha';
|
|
|
|
let notificationsStub = Service.extend({
|
|
alerts: emberA()
|
|
});
|
|
|
|
describe('Integration: Component: gh-alerts', function () {
|
|
setupComponentTest('gh-alerts', {
|
|
integration: true
|
|
});
|
|
|
|
beforeEach(function () {
|
|
this.register('service:notifications', notificationsStub);
|
|
this.inject.service('notifications', {as: 'notifications'});
|
|
|
|
this.set('notifications.alerts', [
|
|
{message: 'First', type: 'error'},
|
|
{message: 'Second', type: 'warn'}
|
|
]);
|
|
});
|
|
|
|
it('renders', function () {
|
|
this.render(hbs`{{gh-alerts}}`);
|
|
expect(this.$('.gh-alerts').length).to.equal(1);
|
|
expect(this.$('.gh-alerts').children().length).to.equal(2);
|
|
|
|
this.set('notifications.alerts', emberA());
|
|
expect(this.$('.gh-alerts').children().length).to.equal(0);
|
|
});
|
|
|
|
it('triggers "notify" action when message count changes', function () {
|
|
let expectedCount = 0;
|
|
|
|
// test double for notify action
|
|
this.set('notify', (count) => expect(count).to.equal(expectedCount));
|
|
|
|
this.render(hbs`{{gh-alerts notify=(action notify)}}`);
|
|
|
|
expectedCount = 3;
|
|
this.get('notifications.alerts').pushObject({message: 'Third', type: 'success'});
|
|
|
|
expectedCount = 0;
|
|
this.set('notifications.alerts', emberA());
|
|
});
|
|
});
|