From 85c058e95c04245dacf3ffb6b45a6eceb3253e7b Mon Sep 17 00:00:00 2001 From: shpuld Date: Fri, 28 Dec 2018 21:39:54 +0200 Subject: New routes, notifications, other impovements in side drwaer --- .../notification_utils/notification_utils.spec.js | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 test/unit/specs/services/notification_utils/notification_utils.spec.js (limited to 'test/unit/specs/services/notification_utils/notification_utils.spec.js') diff --git a/test/unit/specs/services/notification_utils/notification_utils.spec.js b/test/unit/specs/services/notification_utils/notification_utils.spec.js new file mode 100644 index 00000000..c44b8c9e --- /dev/null +++ b/test/unit/specs/services/notification_utils/notification_utils.spec.js @@ -0,0 +1,88 @@ +import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js' + +describe('NotificationUtils', () => { + describe('visibleNotificationsFromStore', () => { + it('should return sorted notifications with configured types', () => { + const store = { + state: { + statuses: { + notifications: { + data: [ + { + action: { id: 1 }, + type: 'like' + }, + { + action: { id: 2 }, + type: 'mention' + }, + { + action: { id: 3 }, + type: 'repeat' + } + ] + } + }, + config: { + notificationVisibility: { + likes: true, + repeats: true, + mentions: false + } + } + } + } + const expected = [ + { + action: { id: 3 }, + type: 'repeat' + }, + { + action: { id: 1 }, + type: 'like' + } + ] + expect(NotificationUtils.visibleNotificationsFromStore(store)).to.eql(expected) + }) + }) + + describe('unseenNotificationsFromStore', () => { + it('should return only notifications not marked as seen', () => { + const store = { + state: { + statuses: { + notifications: { + data: [ + { + action: { id: 1 }, + type: 'like', + seen: false + }, + { + action: { id: 2 }, + type: 'mention', + seen: true + } + ] + } + }, + config: { + notificationVisibility: { + likes: true, + repeats: true, + mentions: false + } + } + } + } + const expected = [ + { + action: { id: 1 }, + type: 'like', + seen: false + } + ] + expect(NotificationUtils.unseenNotificationsFromStore(store)).to.eql(expected) + }) + }) +}) -- cgit v1.2.3-70-g09d2