fix tests
This commit is contained in:
parent
080a2b00ba
commit
25d0d16dbb
10 changed files with 203 additions and 204 deletions
|
|
@ -1,13 +1,15 @@
|
|||
import { setActivePinia } from 'pinia'
|
||||
import { createTestingPinia } from '@pinia/testing'
|
||||
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
import { useNotificationsStore } from 'src/stores/notifications.js'
|
||||
|
||||
import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js'
|
||||
|
||||
describe('NotificationUtils', () => {
|
||||
beforeEach(() => {
|
||||
const store = useSyncConfigStore(createTestingPinia())
|
||||
store.mergedConfig = {
|
||||
setActivePinia(createTestingPinia())
|
||||
useSyncConfigStore().mergedConfig = {
|
||||
notificationVisibility: {
|
||||
likes: true,
|
||||
repeats: true,
|
||||
|
|
@ -16,31 +18,26 @@ describe('NotificationUtils', () => {
|
|||
}
|
||||
})
|
||||
|
||||
describe('filteredNotificationsFromStore', () => {
|
||||
describe('filteredNotifications', () => {
|
||||
it('should return sorted notifications with configured types', () => {
|
||||
const store = {
|
||||
state: {
|
||||
notifications: {
|
||||
data: [
|
||||
{
|
||||
id: 1,
|
||||
action: { id: '1' },
|
||||
type: 'like',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
action: { id: '2' },
|
||||
type: 'mention',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
action: { id: '3' },
|
||||
type: 'repeat',
|
||||
},
|
||||
],
|
||||
},
|
||||
useNotificationsStore().data = [
|
||||
{
|
||||
id: 1,
|
||||
action: { id: '1' },
|
||||
type: 'like',
|
||||
},
|
||||
}
|
||||
{
|
||||
id: 2,
|
||||
action: { id: '2' },
|
||||
type: 'mention',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
action: { id: '3' },
|
||||
type: 'repeat',
|
||||
},
|
||||
]
|
||||
|
||||
const expected = [
|
||||
{
|
||||
action: { id: '3' },
|
||||
|
|
@ -54,7 +51,7 @@ describe('NotificationUtils', () => {
|
|||
},
|
||||
]
|
||||
expect(
|
||||
NotificationUtils.filteredNotificationsFromStore(store, {
|
||||
NotificationUtils.filteredNotifications({
|
||||
mentions: false,
|
||||
likes: true,
|
||||
repeats: true,
|
||||
|
|
@ -63,26 +60,21 @@ describe('NotificationUtils', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('unseenNotificationsFromStore', () => {
|
||||
describe('unseenNotifications', () => {
|
||||
it('should return only notifications not marked as seen', () => {
|
||||
const store = {
|
||||
state: {
|
||||
notifications: {
|
||||
data: [
|
||||
{
|
||||
action: { id: '1' },
|
||||
type: 'like',
|
||||
seen: false,
|
||||
},
|
||||
{
|
||||
action: { id: '2' },
|
||||
type: 'mention',
|
||||
seen: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
useNotificationsStore().data = [
|
||||
{
|
||||
action: { id: '1' },
|
||||
type: 'like',
|
||||
seen: false,
|
||||
},
|
||||
}
|
||||
{
|
||||
action: { id: '2' },
|
||||
type: 'mention',
|
||||
seen: true,
|
||||
},
|
||||
]
|
||||
|
||||
const expected = [
|
||||
{
|
||||
action: { id: '1' },
|
||||
|
|
@ -91,7 +83,7 @@ describe('NotificationUtils', () => {
|
|||
},
|
||||
]
|
||||
expect(
|
||||
NotificationUtils.unseenNotificationsFromStore(store, {
|
||||
NotificationUtils.unseenNotifications({
|
||||
likes: true,
|
||||
repeats: true,
|
||||
mentions: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue