2015-06-19 00:56:18 +03:00
|
|
|
/* jshint expr:true */
|
|
|
|
import { expect } from 'chai';
|
|
|
|
import {
|
|
|
|
describeComponent,
|
|
|
|
it
|
|
|
|
}
|
|
|
|
from 'ember-mocha';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
|
|
|
|
describeComponent(
|
|
|
|
'gh-notification',
|
2015-10-06 19:31:03 +03:00
|
|
|
'Unit: Component: gh-notification',
|
|
|
|
{
|
|
|
|
unit: true
|
2015-06-19 00:56:18 +03:00
|
|
|
// specify the other units that are required for this test
|
|
|
|
// needs: ['component:foo', 'helper:bar']
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
it('closes notification through notifications service', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let component = this.subject();
|
|
|
|
let notifications = {};
|
|
|
|
let notification = {message: 'Test close', type: 'success'};
|
2015-06-19 00:56:18 +03:00
|
|
|
|
|
|
|
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) {
|
2015-10-28 14:36:45 +03:00
|
|
|
let component = this.subject();
|
|
|
|
let notifications = {};
|
|
|
|
let notification = {message: 'Test close', type: 'success'};
|
2015-06-19 00:56:18 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|