2017-05-29 21:50:03 +03:00
|
|
|
import sinon from 'sinon';
|
2016-11-24 01:50:57 +03:00
|
|
|
import {describe, it} from 'mocha';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {expect} from 'chai';
|
2016-11-24 01:50:57 +03:00
|
|
|
import {setupComponentTest} from 'ember-mocha';
|
2015-06-19 00:56:18 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
describe('Unit: Component: gh-notification', function () {
|
|
|
|
setupComponentTest('gh-notification', {
|
2017-03-29 01:22:02 +03:00
|
|
|
unit: true,
|
2015-06-19 00:56:18 +03:00
|
|
|
// specify the other units that are required for this test
|
2018-03-19 12:57:31 +03:00
|
|
|
needs: ['service:notifications', 'helper:svg-jar']
|
2016-11-24 01:50:57 +03:00
|
|
|
});
|
2015-06-19 00:56:18 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
it('closes notification through notifications service', function () {
|
|
|
|
let component = this.subject();
|
|
|
|
let notifications = {};
|
|
|
|
let notification = {message: 'Test close', type: 'success'};
|
2015-06-19 00:56:18 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
notifications.closeNotification = sinon.spy();
|
|
|
|
component.set('notifications', notifications);
|
|
|
|
component.set('message', notification);
|
2015-06-19 00:56:18 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
this.$().find('button').click();
|
|
|
|
|
|
|
|
expect(notifications.closeNotification.calledWith(notification)).to.be.true;
|
|
|
|
});
|
|
|
|
|
2019-02-11 14:43:23 +03:00
|
|
|
// skipped due to random failures on Travis - https://github.com/TryGhost/Ghost/issues/10308
|
|
|
|
it.skip('closes notification when animationend event is triggered', function (done) {
|
2016-11-24 01:50:57 +03:00
|
|
|
let component = this.subject();
|
|
|
|
let notifications = {};
|
|
|
|
let 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 () {
|
2015-06-19 00:56:18 +03:00
|
|
|
expect(notifications.closeNotification.calledWith(notification)).to.be.true;
|
2016-11-24 01:50:57 +03:00
|
|
|
done();
|
|
|
|
}, 150);
|
|
|
|
});
|
|
|
|
});
|