aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshpuld <shp@cock.li>2018-12-28 21:39:54 +0200
committershpuld <shp@cock.li>2018-12-28 21:39:54 +0200
commit85c058e95c04245dacf3ffb6b45a6eceb3253e7b (patch)
treee4a60a67ead56c8d4bdf675bfcb3a1fe914dc7b9 /test
parent47520818180eb9f0eb8d98fbed716ce8c72a46c1 (diff)
New routes, notifications, other impovements in side drwaer
Diffstat (limited to 'test')
-rw-r--r--test/unit/specs/components/user_profile.spec.js3
-rw-r--r--test/unit/specs/services/notification_utils/notification_utils.spec.js88
2 files changed, 90 insertions, 1 deletions
diff --git a/test/unit/specs/components/user_profile.spec.js b/test/unit/specs/components/user_profile.spec.js
index b7743f1f..613f65af 100644
--- a/test/unit/specs/components/user_profile.spec.js
+++ b/test/unit/specs/components/user_profile.spec.js
@@ -7,7 +7,8 @@ const localVue = createLocalVue()
localVue.use(Vuex)
const mutations = {
- clearTimeline: () => {}
+ clearTimeline: () => {},
+ setError: () => {}
}
const externalProfileStore = new Vuex.Store({
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)
+ })
+ })
+})