0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Grouped "browse" unit tests together

refs https://linear.app/tryghost/issue/CORE-64/resolve-undissmissable-update-notification-banners

- Before making changes + adding more tests to the notifications test suite grouped related "browse" tests into a describe block. Housekeeping :)
This commit is contained in:
Naz 2021-10-11 13:07:35 +02:00
parent 1249254a68
commit d948be5bcb

View file

@ -6,6 +6,50 @@ const Notifications = require('../../../../../core/server/services/notifications
const {owner} = require('../../../../utils/fixtures/context');
describe('Notifications Service', function () {
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: false,
top: true,
message: 'Hello test world!'
}]
});
allNotifications.length.should.equal(0);
notificationsToAdd.length.should.equal(1);
const createdNotification = notificationsToAdd[0];
createdNotification.id.should.not.be.undefined();
createdNotification.custom.should.be.true();
createdNotification.createdAt.should.not.be.undefined();
createdNotification.status.should.equal('alert');
createdNotification.type.should.equal('info');
createdNotification.dismissible.should.be.false();
createdNotification.top.should.be.true();
createdNotification.message.should.equal('Hello test world!');
createdNotification.createdAtVersion.should.equal('4.1.0');
});
});
describe('browse', function () {
it('can browse non-major version upgrade notifications', function () {
const settingsCache = {
get: sinon.fake.returns([{
@ -154,48 +198,6 @@ describe('Notifications Service', function () {
should.exist(notifications);
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: false,
top: true,
message: 'Hello test world!'
}]
});
allNotifications.length.should.equal(0);
notificationsToAdd.length.should.equal(1);
const createdNotification = notificationsToAdd[0];
createdNotification.id.should.not.be.undefined();
createdNotification.custom.should.be.true();
createdNotification.createdAt.should.not.be.undefined();
createdNotification.status.should.equal('alert');
createdNotification.type.should.equal('info');
createdNotification.dismissible.should.be.false();
createdNotification.top.should.be.true();
createdNotification.message.should.equal('Hello test world!');
createdNotification.createdAtVersion.should.equal('4.1.0');
});
});
describe('Stored notifications data corruption recovery', function () {