Ghost/ghost/admin/tests/integration/components/gh-notification-test.js

40 lines
1.5 KiB
JavaScript
Raw Normal View History

/* jshint expr:true */
import {expect} from 'chai';
2016-11-24 01:50:57 +03:00
import {describe, it} from 'mocha';
import {setupComponentTest} from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
2016-11-24 01:50:57 +03:00
describe('Integration: Component: gh-notification', function () {
setupComponentTest('gh-notification', {
integration: true
2016-11-24 01:50:57 +03:00
});
2016-11-24 01:50:57 +03:00
it('renders', function () {
this.set('message', {message: 'Test message', type: 'success'});
2016-11-24 01:50:57 +03:00
this.render(hbs`{{gh-notification message=message}}`);
2016-11-24 01:50:57 +03:00
expect(this.$('article.gh-notification')).to.have.length(1);
let $notification = this.$('.gh-notification');
2016-11-24 01:50:57 +03:00
expect($notification.hasClass('gh-notification-passive')).to.be.true;
expect($notification.text()).to.match(/Test message/);
});
2016-11-24 01:50:57 +03:00
it('maps message types to CSS classes', function () {
this.set('message', {message: 'Test message', type: 'success'});
2016-11-24 01:50:57 +03:00
this.render(hbs`{{gh-notification message=message}}`);
let $notification = this.$('.gh-notification');
2016-11-24 01:50:57 +03:00
this.set('message.type', 'success');
expect($notification.hasClass('gh-notification-green'), 'success class isn\'t green').to.be.true;
2016-11-24 01:50:57 +03:00
this.set('message.type', 'error');
expect($notification.hasClass('gh-notification-red'), 'success class isn\'t red').to.be.true;
this.set('message.type', 'warn');
expect($notification.hasClass('gh-notification-yellow'), 'success class isn\'t yellow').to.be.true;
});
});