mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Added basic unit test to cover notifications' service add method
refs https://linear.app/tryghost/issue/CORE-64/resolve-undissmissable-update-notification-banners - We aim for full unit test coverage in our libraries and services. The very basic method coverage was missing so adding it!
This commit is contained in:
parent
7555020a49
commit
e69fa71584
1 changed files with 32 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
const should = require('should');
|
||||
const sinon = require('sinon');
|
||||
|
||||
const moment = require('moment');
|
||||
const Notifications = require('../../../../../core/server/services/notifications/notifications');
|
||||
const {owner} = require('../../../../utils/fixtures/context');
|
||||
|
||||
|
@ -154,6 +155,37 @@ describe('Notifications Service', function () {
|
|||
notifications.length.should.equal(0);
|
||||
});
|
||||
|
||||
describe('add', function () {
|
||||
it('adds a single notification when no previous exist', function () {
|
||||
const existingNotifications = [];
|
||||
const settingsCache = {
|
||||
get: sinon.fake.returns(existingNotifications)
|
||||
};
|
||||
|
||||
const notificationsSvc = new Notifications({
|
||||
settingsCache,
|
||||
ghostVersion: {
|
||||
full: '4.1.0'
|
||||
}
|
||||
});
|
||||
|
||||
const {allNotifications, notificationsToAdd} = notificationsSvc.add({
|
||||
notifications: [{
|
||||
custom: true,
|
||||
createdAt: moment().toDate(),
|
||||
status: 'alert',
|
||||
type: 'info',
|
||||
dismissible: true,
|
||||
top: true,
|
||||
message: 'Hello test world!'
|
||||
}]
|
||||
});
|
||||
|
||||
allNotifications.length.should.equal(0);
|
||||
notificationsToAdd.length.should.equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Stored notifications data corruption recovery', function () {
|
||||
it('should correct broken notifications data on browse', function () {
|
||||
const settingsCache = {
|
||||
|
|
Loading…
Add table
Reference in a new issue