2017-03-21 11:24:11 +03:00
|
|
|
var should = require('should'), // jshint ignore:line
|
|
|
|
rewire = require('rewire'),
|
2016-08-11 10:58:51 +03:00
|
|
|
NotificationAPI = rewire('../../../server/api/notifications');
|
|
|
|
|
|
|
|
describe('UNIT: Notification API', function () {
|
|
|
|
it('ensure non duplicates', function (done) {
|
|
|
|
var options = {context: {internal: true}},
|
|
|
|
notifications = [{
|
|
|
|
type: 'info',
|
|
|
|
message: 'Hello, this is dog'
|
|
|
|
}],
|
|
|
|
notificationStore = NotificationAPI.__get__('notificationsStore');
|
|
|
|
|
|
|
|
NotificationAPI.add({notifications: notifications}, options)
|
|
|
|
.then(function () {
|
|
|
|
notificationStore.length.should.eql(1);
|
|
|
|
return NotificationAPI.add({notifications: notifications}, options);
|
|
|
|
})
|
|
|
|
.then(function () {
|
|
|
|
notificationStore.length.should.eql(1);
|
|
|
|
|
|
|
|
notifications.push({
|
|
|
|
type: 'info',
|
|
|
|
message: 'Hello, this is cat'
|
|
|
|
});
|
|
|
|
|
|
|
|
return NotificationAPI.add({notifications: notifications}, options);
|
|
|
|
})
|
|
|
|
.then(function () {
|
|
|
|
notificationStore.length.should.eql(2);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
});
|