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