mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
47e00900cc
no issue - change out should.equal for // jshint ignore:line - ensure should is the first require in every test, and ALWAYS require - make sinon the second require, and sandbox the last thing - ALWAYS use sandbox, futureproofs tests against contributors who don't know it - change require formatting
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
var should = require('should'), // jshint ignore:line
|
|
rewire = require('rewire'),
|
|
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);
|
|
});
|
|
});
|