mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
c5a8a0c860
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
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
/* jshint expr:true */
|
|
import { expect } from 'chai';
|
|
import {
|
|
describeComponent,
|
|
it
|
|
}
|
|
from 'ember-mocha';
|
|
import sinon from 'sinon';
|
|
|
|
describeComponent(
|
|
'gh-notification',
|
|
'Unit: Component: gh-notification',
|
|
{
|
|
unit: true
|
|
// specify the other units that are required for this test
|
|
// needs: ['component:foo', 'helper:bar']
|
|
},
|
|
function () {
|
|
it('closes notification through notifications service', function () {
|
|
var component = this.subject(),
|
|
notifications = {},
|
|
notification = {message: 'Test close', type: 'success'};
|
|
|
|
notifications.closeNotification = sinon.spy();
|
|
component.set('notifications', notifications);
|
|
component.set('message', notification);
|
|
|
|
this.$().find('button').click();
|
|
|
|
expect(notifications.closeNotification.calledWith(notification)).to.be.true;
|
|
});
|
|
|
|
it('closes notification when animationend event is triggered', function (done) {
|
|
var component = this.subject(),
|
|
notifications = {},
|
|
notification = {message: 'Test close', type: 'success'};
|
|
|
|
notifications.closeNotification = sinon.spy();
|
|
component.set('notifications', notifications);
|
|
component.set('message', notification);
|
|
|
|
// shorten the animation delay to speed up test
|
|
this.$().css('animation-delay', '0.1s');
|
|
setTimeout(function () {
|
|
expect(notifications.closeNotification.calledWith(notification)).to.be.true;
|
|
done();
|
|
}, 150);
|
|
});
|
|
}
|
|
);
|