2015-06-18 22:56:18 +01:00
|
|
|
/* jshint expr:true */
|
|
|
|
import Ember from 'ember';
|
|
|
|
import { expect } from 'chai';
|
|
|
|
import {
|
|
|
|
describeComponent,
|
|
|
|
it
|
|
|
|
}
|
|
|
|
from 'ember-mocha';
|
|
|
|
|
|
|
|
describeComponent(
|
|
|
|
'gh-notifications',
|
2015-10-06 17:31:03 +01:00
|
|
|
'Unit: Component: gh-notifications', {
|
|
|
|
unit: true,
|
2015-06-18 22:56:18 +01:00
|
|
|
needs: ['component:gh-notification']
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
// Stub the notifications service
|
|
|
|
var notifications = Ember.Object.create();
|
|
|
|
notifications.notifications = Ember.A();
|
|
|
|
notifications.notifications.pushObject({message: 'First', type: 'error'});
|
|
|
|
notifications.notifications.pushObject({message: 'Second', type: 'warn'});
|
|
|
|
|
|
|
|
this.subject().set('notifications', notifications);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders', function () {
|
|
|
|
// creates the component instance
|
|
|
|
var component = this.subject();
|
|
|
|
expect(component._state).to.equal('preRender');
|
|
|
|
|
|
|
|
// renders the component on the page
|
|
|
|
this.render();
|
|
|
|
expect(component._state).to.equal('inDOM');
|
|
|
|
|
|
|
|
expect(this.$().prop('tagName')).to.equal('ASIDE');
|
|
|
|
expect(this.$().hasClass('gh-notifications')).to.be.true;
|
|
|
|
expect(this.$().children().length).to.equal(2);
|
|
|
|
|
|
|
|
Ember.run(function () {
|
|
|
|
component.set('notifications.notifications', Ember.A());
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(this.$().children().length).to.equal(0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|