diff options
| author | Shpuld Shpludson <shp@cock.li> | 2018-12-31 17:35:31 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2018-12-31 17:35:31 +0000 |
| commit | 76cfb15b3c76531b7c3da0261720d13004c8cfdd (patch) | |
| tree | 12d63c530bc9080c8d7449a5f393d0549355b288 /test/unit/specs/services/notification_utils/notification_utils.spec.js | |
| parent | 7aa42c01eb5f05c2e3ed71fc52be6a30e45802bf (diff) | |
| parent | ace042015e77e507d6323c493596943dd8c657bb (diff) | |
Merge branch 'feature/replace-panel-switcher' into 'develop'
Mobile side drawer
See merge request pleroma/pleroma-fe!443
Diffstat (limited to 'test/unit/specs/services/notification_utils/notification_utils.spec.js')
| -rw-r--r-- | test/unit/specs/services/notification_utils/notification_utils.spec.js | 88 |
1 files changed, 88 insertions, 0 deletions
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) + }) + }) +}) |
