diff --git a/test/api/v3/unit/libs/cron.test.js b/test/api/v3/unit/libs/cron.test.js index d65409d727..75d31f5f4a 100644 --- a/test/api/v3/unit/libs/cron.test.js +++ b/test/api/v3/unit/libs/cron.test.js @@ -704,14 +704,14 @@ describe('cron', () => { cron({user, tasksByType, daysMissed, analytics}); - expect(user.notifications.length - notifsBefore2).to.equal(1); - expect(user.notifications[1].type).to.not.equal('CRON'); - expect(user.notifications[2].type).to.equal('CRON'); - expect(user.notifications[2].data).to.eql({ + expect(user.notifications.length - notifsBefore2).to.equal(0); + expect(user.notifications[0].type).to.not.equal('CRON'); + expect(user.notifications[1].type).to.equal('CRON'); + expect(user.notifications[1].data).to.eql({ hp: user.stats.hp - hpBefore2 - (hpBefore2 - hpBefore1), mp: user.stats.mp - mpBefore2 - (mpBefore2 - mpBefore1), }); - expect(user.notifications[1].type).to.not.equal('CRON'); + expect(user.notifications[0].type).to.not.equal('CRON'); }); }); @@ -785,9 +785,7 @@ describe('cron', () => { cron({user, tasksByType, daysMissed, analytics}); cron({user, tasksByType, daysMissed, analytics}); - let filteredNotifications = filter(user.notifications, function filterNotifications (notification) { - return notification.type === 'LOGIN_INCENTIVE'; - }); + let filteredNotifications = user.notifications.filter(n => n.type === 'LOGIN_INCENTIVE'); expect(filteredNotifications.length).to.equal(1); }); diff --git a/website/server/libs/cron.js b/website/server/libs/cron.js index eb5f2f7d34..367356922b 100644 --- a/website/server/libs/cron.js +++ b/website/server/libs/cron.js @@ -131,7 +131,7 @@ function trackCronAnalytics (analytics, user, _progress, options) { function awardLoginIncentives (user) { if (user.loginIncentives > 50) return; - // Remove old noitification if it exists + // Remove old notifications if they exists user.notifications .toObject() .find((notif, index) => {