1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/tests/integration/components/gh-alert-test.js
Kevin Ansfield 55840eb57f Avoid duplicate alerts, clear alerts on successful retry or sign-in
closes #5903, refs #5409
- switch alert/notification component tests from unit to integration where appropriate
- rename `notifications.closeAll` to `notifications.clearAll` to better represent it's behaviour
- add concept of a "key" to alerts/notifications and ability to close only specified keys through notifications service
- close duplicate alerts/notifications before showing a new one
- specify a key for all existing alerts
- close failure alerts on successful retries
- clear all currently displayed alerts on successful sign-in
2015-10-12 19:21:30 +01:00

46 lines
1.5 KiB
JavaScript

/* jshint expr:true */
import { expect } from 'chai';
import {
describeComponent,
it
} from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
describeComponent(
'gh-alert',
'Integration: Component: gh-alert',
{
integration: true
},
function () {
it('renders', function () {
this.set('message', {message: 'Test message', type: 'success'});
this.render(hbs`{{gh-alert message=message}}`);
expect(this.$('article.gh-alert')).to.have.length(1);
let $alert = this.$('.gh-alert');
expect($alert.text()).to.match(/Test message/);
});
it('maps message types to CSS classes', function () {
this.set('message', {message: 'Test message', type: 'success'});
this.render(hbs`{{gh-alert message=message}}`);
let $alert = this.$('.gh-alert');
this.set('message.type', 'success');
expect($alert.hasClass('gh-alert-green'), 'success class isn\'t green').to.be.true;
this.set('message.type', 'error');
expect($alert.hasClass('gh-alert-red'), 'success class isn\'t red').to.be.true;
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;
});
}
);