mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 17:32:15 +03:00
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
|
var rewire = require('rewire'),
|
||
|
/*jshint unused:false*/
|
||
|
should = require('should'),
|
||
|
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);
|
||
|
});
|
||
|
});
|