1
0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-22 10:21:36 +03:00
Ghost/core/test/unit/api/notifications_spec.js
Hannah Wolfe 47e00900cc 💄 🐷 Test consistency ()
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
2017-03-21 09:24:11 +01:00

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);
});
});