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