2018-12-29 06:39:54 +11:00
|
|
|
import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js'
|
|
|
|
|
|
|
|
describe('NotificationUtils', () => {
|
2020-01-15 00:28:57 +11:00
|
|
|
describe('filteredNotificationsFromStore', () => {
|
2018-12-29 06:39:54 +11:00
|
|
|
it('should return sorted notifications with configured types', () => {
|
|
|
|
const store = {
|
|
|
|
state: {
|
|
|
|
statuses: {
|
|
|
|
notifications: {
|
|
|
|
data: [
|
|
|
|
{
|
2019-03-14 23:06:40 +11:00
|
|
|
id: 1,
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '1' },
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'like'
|
|
|
|
},
|
|
|
|
{
|
2019-03-14 23:06:40 +11:00
|
|
|
id: 2,
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '2' },
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'mention'
|
|
|
|
},
|
|
|
|
{
|
2019-03-14 23:06:40 +11:00
|
|
|
id: 3,
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '3' },
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'repeat'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
config: {
|
|
|
|
notificationVisibility: {
|
|
|
|
likes: true,
|
|
|
|
repeats: true,
|
|
|
|
mentions: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const expected = [
|
|
|
|
{
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '3' },
|
2019-03-14 23:06:40 +11:00
|
|
|
id: 3,
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'repeat'
|
|
|
|
},
|
|
|
|
{
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '1' },
|
2019-03-14 23:06:40 +11:00
|
|
|
id: 1,
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'like'
|
|
|
|
}
|
|
|
|
]
|
2020-01-15 00:28:57 +11:00
|
|
|
expect(NotificationUtils.filteredNotificationsFromStore(store)).to.eql(expected)
|
2018-12-29 06:39:54 +11:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('unseenNotificationsFromStore', () => {
|
|
|
|
it('should return only notifications not marked as seen', () => {
|
|
|
|
const store = {
|
|
|
|
state: {
|
|
|
|
statuses: {
|
|
|
|
notifications: {
|
|
|
|
data: [
|
|
|
|
{
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '1' },
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'like',
|
|
|
|
seen: false
|
|
|
|
},
|
|
|
|
{
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '2' },
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'mention',
|
|
|
|
seen: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
config: {
|
|
|
|
notificationVisibility: {
|
|
|
|
likes: true,
|
|
|
|
repeats: true,
|
|
|
|
mentions: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const expected = [
|
|
|
|
{
|
2019-01-11 11:38:23 +11:00
|
|
|
action: { id: '1' },
|
2018-12-29 06:39:54 +11:00
|
|
|
type: 'like',
|
|
|
|
seen: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
expect(NotificationUtils.unseenNotificationsFromStore(store)).to.eql(expected)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|