fix tests
This commit is contained in:
parent
080a2b00ba
commit
25d0d16dbb
10 changed files with 203 additions and 204 deletions
|
|
@ -8,7 +8,7 @@ import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||||
import { useUsersStore } from 'src/stores/users.js'
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
export default (store) => {
|
export default () => {
|
||||||
const validateAuthenticatedRoute = (to, from, next) => {
|
const validateAuthenticatedRoute = (to, from, next) => {
|
||||||
if (useUsersStore().currentUser) {
|
if (useUsersStore().currentUser) {
|
||||||
next()
|
next()
|
||||||
|
|
|
||||||
|
|
@ -571,9 +571,7 @@ const PostStatusForm = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global stuff
|
// Global stuff
|
||||||
currentUser() {
|
...mapState(useUsersStore, ['currentUser']),
|
||||||
return useUsersStore().currentUser
|
|
||||||
},
|
|
||||||
...mapState(useMergedConfigStore, ['mergedConfig']),
|
...mapState(useMergedConfigStore, ['mergedConfig']),
|
||||||
...mapState(useInterfaceStore, {
|
...mapState(useInterfaceStore, {
|
||||||
mobileLayout: (store) => store.mobileLayout,
|
mobileLayout: (store) => store.mobileLayout,
|
||||||
|
|
|
||||||
|
|
@ -119,9 +119,7 @@ export const useNotificationsStore = defineStore('notifications', {
|
||||||
addNewNotifications(result, older) {
|
addNewNotifications(result, older) {
|
||||||
const { timestamp, data } = result
|
const { timestamp, data } = result
|
||||||
|
|
||||||
const notifications = older
|
const notifications = older ? data : [...data].reverse()
|
||||||
? data
|
|
||||||
: [...data].reverse()
|
|
||||||
|
|
||||||
useUsersStore().addNewUsers({
|
useUsersStore().addNewUsers({
|
||||||
timestamp,
|
timestamp,
|
||||||
|
|
@ -199,7 +197,9 @@ export const useNotificationsStore = defineStore('notifications', {
|
||||||
|
|
||||||
maybeShowNotification(
|
maybeShowNotification(
|
||||||
useMergedConfigStore().mergedConfig.notificationVisibility,
|
useMergedConfigStore().mergedConfig.notificationVisibility,
|
||||||
Object.values(useSyncConfigStore().prefsStorage.simple.muteFilters ?? {}),
|
Object.values(
|
||||||
|
useSyncConfigStore().prefsStorage.simple.muteFilters ?? {},
|
||||||
|
),
|
||||||
notification,
|
notification,
|
||||||
useI18nStore().i18n,
|
useI18nStore().i18n,
|
||||||
)
|
)
|
||||||
|
|
@ -275,7 +275,8 @@ export const useNotificationsStore = defineStore('notifications', {
|
||||||
wipeStatuses(ids) {
|
wipeStatuses(ids) {
|
||||||
const set = new Set(ids)
|
const set = new Set(ids)
|
||||||
this.data.forEach((notification) => {
|
this.data.forEach((notification) => {
|
||||||
const status = isStatusNotification(notification.type) && notification.status
|
const status =
|
||||||
|
isStatusNotification(notification.type) && notification.status
|
||||||
if (status && set.has(status.id)) {
|
if (status && set.has(status.id)) {
|
||||||
this.idStore.delete(notification.id)
|
this.idStore.delete(notification.id)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
test/fixtures/setup_test.js
vendored
1
test/fixtures/setup_test.js
vendored
|
|
@ -26,7 +26,6 @@ const getDefaultOpts = ({
|
||||||
global: {
|
global: {
|
||||||
plugins: [
|
plugins: [
|
||||||
applyAfterStore(makeMockStore(), afterStore),
|
applyAfterStore(makeMockStore(), afterStore),
|
||||||
createTestingPinia(),
|
|
||||||
VueVirtualScroller,
|
VueVirtualScroller,
|
||||||
createRouter({
|
createRouter({
|
||||||
history: createMemoryHistory(),
|
history: createMemoryHistory(),
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,10 @@ import { createStore } from 'vuex'
|
||||||
|
|
||||||
import routes from 'src/boot/routes'
|
import routes from 'src/boot/routes'
|
||||||
|
|
||||||
const store = createStore({
|
|
||||||
state: {
|
|
||||||
instance: {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('routes', () => {
|
describe('routes', () => {
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createMemoryHistory(),
|
history: createMemoryHistory(),
|
||||||
routes: routes(store),
|
routes: routes(),
|
||||||
})
|
})
|
||||||
|
|
||||||
it('root path', async () => {
|
it('root path', async () => {
|
||||||
|
|
@ -24,12 +18,9 @@ describe('routes', () => {
|
||||||
|
|
||||||
const matchedComponents = router.currentRoute.value.matched
|
const matchedComponents = router.currentRoute.value.matched
|
||||||
|
|
||||||
expect(
|
expect(matchedComponents[0].components.default.__file).to.contain(
|
||||||
Object.hasOwn(
|
'/timeline.vue',
|
||||||
matchedComponents[0].components.default.components,
|
)
|
||||||
'Timeline',
|
|
||||||
),
|
|
||||||
).to.eql(true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("user's profile", async () => {
|
it("user's profile", async () => {
|
||||||
|
|
@ -38,7 +29,7 @@ describe('routes', () => {
|
||||||
const matchedComponents = router.currentRoute.value.matched
|
const matchedComponents = router.currentRoute.value.matched
|
||||||
|
|
||||||
expect(matchedComponents[0].components.default.__file).to.contain(
|
expect(matchedComponents[0].components.default.__file).to.contain(
|
||||||
'user_profile.vue',
|
'/user_profile.vue',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -48,7 +39,7 @@ describe('routes', () => {
|
||||||
const matchedComponents = router.currentRoute.value.matched
|
const matchedComponents = router.currentRoute.value.matched
|
||||||
|
|
||||||
expect(matchedComponents[0].components.default.__file).to.contain(
|
expect(matchedComponents[0].components.default.__file).to.contain(
|
||||||
'user_profile.vue',
|
'/user_profile.vue',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -57,7 +48,7 @@ describe('routes', () => {
|
||||||
|
|
||||||
const matchedComponents = router.currentRoute.value.matched
|
const matchedComponents = router.currentRoute.value.matched
|
||||||
expect(matchedComponents[0].components.default.__file).to.contain(
|
expect(matchedComponents[0].components.default.__file).to.contain(
|
||||||
'lists.vue',
|
'/lists.vue',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -67,7 +58,7 @@ describe('routes', () => {
|
||||||
const matchedComponents = router.currentRoute.value.matched
|
const matchedComponents = router.currentRoute.value.matched
|
||||||
|
|
||||||
expect(matchedComponents[0].components.default.__file).to.contain(
|
expect(matchedComponents[0].components.default.__file).to.contain(
|
||||||
'lists_timeline.vue',
|
'/timeline.vue',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -77,7 +68,7 @@ describe('routes', () => {
|
||||||
const matchedComponents = router.currentRoute.value.matched
|
const matchedComponents = router.currentRoute.value.matched
|
||||||
|
|
||||||
expect(matchedComponents[0].components.default.__file).to.contain(
|
expect(matchedComponents[0].components.default.__file).to.contain(
|
||||||
'lists_edit.vue',
|
'/lists_edit.vue',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { createTestingPinia } from '@pinia/testing'
|
||||||
import { flushPromises, mount } from '@vue/test-utils'
|
import { flushPromises, mount } from '@vue/test-utils'
|
||||||
import { setActivePinia } from 'pinia'
|
import { setActivePinia } from 'pinia'
|
||||||
import { nextTick } from 'vue'
|
import { nextTick } from 'vue'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
||||||
import { $t, mountOpts, waitForEvent } from '../../../fixtures/setup_test'
|
import { $t, mountOpts, waitForEvent } from '../../../fixtures/setup_test'
|
||||||
|
|
@ -34,13 +35,20 @@ const saveManually = async (wrapper) => {
|
||||||
|
|
||||||
const waitSaveTime = 4000
|
const waitSaveTime = 4000
|
||||||
|
|
||||||
afterEach(() => {
|
const currentUser = {
|
||||||
vi.useRealTimers()
|
id: 'current-user',
|
||||||
})
|
default_scope: 'public',
|
||||||
|
locked: false,
|
||||||
|
}
|
||||||
|
|
||||||
describe('Draft saving', () => {
|
describe('Draft saving', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setActivePinia(createTestingPinia())
|
setActivePinia(createTestingPinia())
|
||||||
|
useUsersStore().currentUser = currentUser
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers()
|
||||||
})
|
})
|
||||||
|
|
||||||
autoSaveOrNot(
|
autoSaveOrNot(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
import { createTestingPinia } from '@pinia/testing'
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
|
import { setActivePinia } from 'pinia'
|
||||||
import { vi } from 'vitest'
|
import { vi } from 'vitest'
|
||||||
|
|
||||||
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
|
||||||
|
|
@ -33,24 +35,18 @@ const repliedStatus2 = {
|
||||||
user: repliedUser,
|
user: repliedUser,
|
||||||
}
|
}
|
||||||
|
|
||||||
const replyMountOpts = (props) =>
|
|
||||||
mountOpts({
|
|
||||||
props,
|
|
||||||
afterStore(store) {
|
|
||||||
useUsersStore().currentUser = currentUser
|
|
||||||
useStatusesStore().allStatuses = {
|
|
||||||
[repliedStatus.id]: repliedStatus,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('PostStatusForm', () => {
|
describe('PostStatusForm', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.useFakeTimers()
|
vi.useFakeTimers()
|
||||||
|
setActivePinia(createTestingPinia())
|
||||||
|
useUsersStore().currentUser = currentUser
|
||||||
|
useStatusesStore().allStatuses = new Map([
|
||||||
|
[repliedStatus.id, repliedStatus],
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Clean empty initial state', () => {
|
it('Clean empty initial state', () => {
|
||||||
const wrapper = mount(PostStatusForm, replyMountOpts())
|
const wrapper = mount(PostStatusForm, mountOpts())
|
||||||
|
|
||||||
expect(wrapper.vm.statusType).to.equal('new')
|
expect(wrapper.vm.statusType).to.equal('new')
|
||||||
expect(wrapper.vm.newStatus.spoilerText).to.eql('')
|
expect(wrapper.vm.newStatus.spoilerText).to.eql('')
|
||||||
|
|
@ -59,7 +55,7 @@ describe('PostStatusForm', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Reset cleans form to pristine state equal to state form was when created', () => {
|
it('Reset cleans form to pristine state equal to state form was when created', () => {
|
||||||
const wrapper = mount(PostStatusForm, replyMountOpts())
|
const wrapper = mount(PostStatusForm, mountOpts())
|
||||||
|
|
||||||
const initial = { ...wrapper.vm.newStatus }
|
const initial = { ...wrapper.vm.newStatus }
|
||||||
wrapper.vm.clearStatus()
|
wrapper.vm.clearStatus()
|
||||||
|
|
@ -70,8 +66,10 @@ describe('PostStatusForm', () => {
|
||||||
it('Initializes a reply form', () => {
|
it('Initializes a reply form', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
repliedStatus: repliedStatus,
|
props: {
|
||||||
|
repliedStatus: repliedStatus,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -93,8 +91,10 @@ describe('PostStatusForm', () => {
|
||||||
it('Copies scope and subject line, disables quoting for locked posts', () => {
|
it('Copies scope and subject line, disables quoting for locked posts', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
repliedStatus: repliedStatus2,
|
props: {
|
||||||
|
repliedStatus: repliedStatus2,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -123,8 +123,10 @@ describe('PostStatusForm', () => {
|
||||||
|
|
||||||
it('Forces direct mode when replying to a DM, mastodon style subject handling', () => {
|
it('Forces direct mode when replying to a DM, mastodon style subject handling', () => {
|
||||||
// We need to initialize pinia first which is happening here...
|
// We need to initialize pinia first which is happening here...
|
||||||
const options = replyMountOpts({
|
const options = mountOpts({
|
||||||
repliedStatus: { ...repliedStatus2, visibility: 'direct' },
|
props: {
|
||||||
|
repliedStatus: { ...repliedStatus2, visibility: 'direct' },
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// ...set our settings...
|
// ...set our settings...
|
||||||
|
|
@ -152,10 +154,12 @@ describe('PostStatusForm', () => {
|
||||||
it('Sets status to statusText without mentions if mentions line is enabled', () => {
|
it('Sets status to statusText without mentions if mentions line is enabled', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
repliedStatus: repliedStatus2,
|
props: {
|
||||||
statusText: 'testing',
|
repliedStatus: repliedStatus2,
|
||||||
mentionsLine: true,
|
statusText: 'testing',
|
||||||
|
mentionsLine: true,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -168,8 +172,10 @@ describe('PostStatusForm', () => {
|
||||||
it('Sets mention when asked for it', () => {
|
it('Sets mention when asked for it', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
profileMention: repliedUser,
|
props: {
|
||||||
|
profileMention: repliedUser,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -182,8 +188,10 @@ describe('PostStatusForm', () => {
|
||||||
it('Initializes quote when reply/quote toggled to quote', () => {
|
it('Initializes quote when reply/quote toggled to quote', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
repliedStatus: repliedStatus2,
|
props: {
|
||||||
|
repliedStatus: repliedStatus2,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -198,8 +206,10 @@ describe('PostStatusForm', () => {
|
||||||
it('Resets quote when reply/quote toggled to reply', () => {
|
it('Resets quote when reply/quote toggled to reply', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
repliedStatus: repliedStatus2,
|
props: {
|
||||||
|
repliedStatus: repliedStatus2,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -215,8 +225,10 @@ describe('PostStatusForm', () => {
|
||||||
it('Initializes and reset quote when toggling quote attachment', () => {
|
it('Initializes and reset quote when toggling quote attachment', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
repliedStatus: repliedStatus2,
|
props: {
|
||||||
|
repliedStatus: repliedStatus2,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -236,17 +248,19 @@ describe('PostStatusForm', () => {
|
||||||
it('Status editing', () => {
|
it('Status editing', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
PostStatusForm,
|
PostStatusForm,
|
||||||
replyMountOpts({
|
mountOpts({
|
||||||
statusId: 'edited',
|
props: {
|
||||||
statusText: 'text',
|
statusId: 'edited',
|
||||||
statusSubject: 'heading',
|
statusText: 'text',
|
||||||
statusIsSensitive: true,
|
statusSubject: 'heading',
|
||||||
statusPoll: {},
|
statusIsSensitive: true,
|
||||||
statusQuote: {},
|
statusPoll: {},
|
||||||
statusFiles: [],
|
statusQuote: {},
|
||||||
statusMediaDescriptions: {},
|
statusFiles: [],
|
||||||
statusVisibility: 'unlisted',
|
statusMediaDescriptions: {},
|
||||||
statusContentType: 'text/markdown',
|
statusVisibility: 'unlisted',
|
||||||
|
statusContentType: 'text/markdown',
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -266,7 +280,7 @@ describe('PostStatusForm', () => {
|
||||||
|
|
||||||
it('Posting should reset idempotency key', async () => {
|
it('Posting should reset idempotency key', async () => {
|
||||||
vi.setSystemTime(new Date(2027, 1, 1, 13))
|
vi.setSystemTime(new Date(2027, 1, 1, 13))
|
||||||
const wrapper = mount(PostStatusForm, replyMountOpts())
|
const wrapper = mount(PostStatusForm, mountOpts())
|
||||||
const oldIdempotency = wrapper.vm.idempotencyKey
|
const oldIdempotency = wrapper.vm.idempotencyKey
|
||||||
|
|
||||||
vi.setSystemTime(new Date(2028, 1, 1, 13))
|
vi.setSystemTime(new Date(2028, 1, 1, 13))
|
||||||
|
|
@ -280,7 +294,7 @@ describe('PostStatusForm', () => {
|
||||||
// TODO Probably better to separate attachment upload/manipulation into its own component?
|
// TODO Probably better to separate attachment upload/manipulation into its own component?
|
||||||
// we need to upload-on-submit for compression setting anyway
|
// we need to upload-on-submit for compression setting anyway
|
||||||
it('Attachments manipulations (moving, adding, removing)', () => {
|
it('Attachments manipulations (moving, adding, removing)', () => {
|
||||||
const wrapper = mount(PostStatusForm, replyMountOpts())
|
const wrapper = mount(PostStatusForm, mountOpts())
|
||||||
|
|
||||||
const i1 = { id: '1', url: 'a' }
|
const i1 = { id: '1', url: 'a' }
|
||||||
const i2 = { id: '2', url: 'b' }
|
const i2 = { id: '2', url: 'b' }
|
||||||
|
|
@ -310,7 +324,7 @@ describe('PostStatusForm', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Attachment descriptions', () => {
|
it('Attachment descriptions', () => {
|
||||||
const wrapper = mount(PostStatusForm, replyMountOpts())
|
const wrapper = mount(PostStatusForm, mountOpts())
|
||||||
|
|
||||||
const i1 = { id: '1', url: 'a' }
|
const i1 = { id: '1', url: 'a' }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,11 @@
|
||||||
|
import { createTestingPinia } from '@pinia/testing'
|
||||||
|
import { setActivePinia } from 'pinia'
|
||||||
import { mount, shallowMount } from '@vue/test-utils'
|
import { mount, shallowMount } from '@vue/test-utils'
|
||||||
|
import { mountOpts } from '../../../fixtures/setup_test'
|
||||||
|
|
||||||
import RichContent from 'src/components/rich_content/rich_content.jsx'
|
import RichContent from 'src/components/rich_content/rich_content.jsx'
|
||||||
|
|
||||||
const attentions = []
|
const attentions = []
|
||||||
const global = {
|
|
||||||
mocks: {
|
|
||||||
$store: {
|
|
||||||
state: {},
|
|
||||||
getters: {
|
|
||||||
mergedConfig: () => ({
|
|
||||||
mentionLinkShowTooltip: true,
|
|
||||||
}),
|
|
||||||
findUserByUrl: () => null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
stubs: {
|
|
||||||
FAIcon: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const makeMention = (who, noClass) => {
|
const makeMention = (who, noClass) => {
|
||||||
attentions.push({ statusnet_profile_url: `https://fake.tld/@${who}` })
|
attentions.push({ statusnet_profile_url: `https://fake.tld/@${who}` })
|
||||||
|
|
@ -37,10 +24,13 @@ const mentionsLine = (times) =>
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
describe('RichContent', () => {
|
describe('RichContent', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setActivePinia(createTestingPinia())
|
||||||
|
})
|
||||||
|
|
||||||
it('renders simple post without exploding', () => {
|
it('renders simple post without exploding', () => {
|
||||||
const html = p('Hello world!')
|
const html = p('Hello world!')
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -48,7 +38,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
|
||||||
})
|
})
|
||||||
|
|
@ -56,8 +46,7 @@ describe('RichContent', () => {
|
||||||
it('unescapes everything as needed', () => {
|
it('unescapes everything as needed', () => {
|
||||||
const html = [p('Testing 'em all'), 'Testing 'em all'].join('')
|
const html = [p('Testing 'em all'), 'Testing 'em all'].join('')
|
||||||
const expected = [p("Testing 'em all"), "Testing 'em all"].join('')
|
const expected = [p("Testing 'em all"), "Testing 'em all"].join('')
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -65,15 +54,14 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('replaces mention with mentionsline', () => {
|
it('replaces mention with mentionsline', () => {
|
||||||
const html = p(makeMention('John'), ' how are you doing today?')
|
const html = p(makeMention('John'), ' how are you doing today?')
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -81,7 +69,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(
|
||||||
compwrap(p(mentionsLine(1), ' how are you doing today?')),
|
compwrap(p(mentionsLine(1), ' how are you doing today?')),
|
||||||
|
|
@ -105,8 +93,7 @@ describe('RichContent', () => {
|
||||||
),
|
),
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -114,7 +101,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
@ -141,8 +128,7 @@ describe('RichContent', () => {
|
||||||
].join(''),
|
].join(''),
|
||||||
].join('\n')
|
].join('\n')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: false,
|
handleLinks: false,
|
||||||
|
|
@ -150,7 +136,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html()).to.eql(compwrap(strippedHtml))
|
expect(wrapper.html()).to.eql(compwrap(strippedHtml))
|
||||||
})
|
})
|
||||||
|
|
@ -162,8 +148,7 @@ describe('RichContent', () => {
|
||||||
'<span class="greentext">>any year</span>',
|
'<span class="greentext">>any year</span>',
|
||||||
].join('\n')
|
].join('\n')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: false,
|
handleLinks: false,
|
||||||
|
|
@ -171,7 +156,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html()).to.eql(compwrap(expected))
|
expect(wrapper.html()).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
@ -179,8 +164,7 @@ describe('RichContent', () => {
|
||||||
it('Does not add greentext and cyantext if setting is set to false', () => {
|
it('Does not add greentext and cyantext if setting is set to false', () => {
|
||||||
const html = ['>preordering videogames', '>any year'].join('\n')
|
const html = ['>preordering videogames', '>any year'].join('\n')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: false,
|
handleLinks: false,
|
||||||
|
|
@ -188,7 +172,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html()).to.eql(compwrap(html))
|
expect(wrapper.html()).to.eql(compwrap(html))
|
||||||
})
|
})
|
||||||
|
|
@ -200,8 +184,7 @@ describe('RichContent', () => {
|
||||||
'<anonymous-stub shortcode="spurdo" islocal="true" class="emoji img" src="about:blank" title=":spurdo:" alt=":spurdo:"></anonymous-stub>',
|
'<anonymous-stub shortcode="spurdo" islocal="true" class="emoji img" src="about:blank" title=":spurdo:" alt=":spurdo:"></anonymous-stub>',
|
||||||
)
|
)
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: false,
|
handleLinks: false,
|
||||||
|
|
@ -209,7 +192,7 @@ describe('RichContent', () => {
|
||||||
emoji: [{ url: 'about:blank', shortcode: 'spurdo' }],
|
emoji: [{ url: 'about:blank', shortcode: 'spurdo' }],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
@ -217,8 +200,7 @@ describe('RichContent', () => {
|
||||||
it("Doesn't add nonexistent emoji to post", () => {
|
it("Doesn't add nonexistent emoji to post", () => {
|
||||||
const html = p('Lol :lol:')
|
const html = p('Lol :lol:')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: false,
|
handleLinks: false,
|
||||||
|
|
@ -226,7 +208,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
|
||||||
})
|
})
|
||||||
|
|
@ -245,8 +227,7 @@ describe('RichContent', () => {
|
||||||
'<span class="greentext">>quote</span>',
|
'<span class="greentext">>quote</span>',
|
||||||
].join('\n')
|
].join('\n')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -254,7 +235,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html()).to.eql(compwrap(expected))
|
expect(wrapper.html()).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
@ -268,8 +249,7 @@ describe('RichContent', () => {
|
||||||
].join('<br>')
|
].join('<br>')
|
||||||
const expected = ['Bruh', 'Bruh', mentionsLine(3), 'Bruh'].join('<br>')
|
const expected = ['Bruh', 'Bruh', mentionsLine(3), 'Bruh'].join('<br>')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -277,7 +257,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
@ -304,8 +284,7 @@ describe('RichContent', () => {
|
||||||
' </p>',
|
' </p>',
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -313,7 +292,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
@ -351,8 +330,7 @@ describe('RichContent', () => {
|
||||||
p('Testing'),
|
p('Testing'),
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const wrapper = mount(RichContent, {
|
const wrapper = mount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -360,7 +338,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
|
|
@ -424,8 +402,7 @@ describe('RichContent', () => {
|
||||||
'Testing',
|
'Testing',
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const wrapper = mount(RichContent, {
|
const wrapper = mount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -433,7 +410,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
|
|
@ -473,8 +450,7 @@ describe('RichContent', () => {
|
||||||
'</p>',
|
'</p>',
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const wrapper = shallowMount(RichContent, {
|
const wrapper = shallowMount(RichContent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks: true,
|
handleLinks: true,
|
||||||
|
|
@ -482,7 +458,7 @@ describe('RichContent', () => {
|
||||||
emoji: [],
|
emoji: [],
|
||||||
html,
|
html,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
|
||||||
})
|
})
|
||||||
|
|
@ -519,14 +495,13 @@ describe('RichContent', () => {
|
||||||
const ptest = (handleLinks, vhtml) => {
|
const ptest = (handleLinks, vhtml) => {
|
||||||
const t0 = performance.now()
|
const t0 = performance.now()
|
||||||
|
|
||||||
const wrapper = mount(TestComponent, {
|
const wrapper = mount(TestComponent, mountOpts({
|
||||||
global,
|
|
||||||
props: {
|
props: {
|
||||||
attentions,
|
attentions,
|
||||||
handleLinks,
|
handleLinks,
|
||||||
vhtml,
|
vhtml,
|
||||||
},
|
},
|
||||||
})
|
}))
|
||||||
|
|
||||||
const t1 = performance.now()
|
const t1 = performance.now()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
|
import { setActivePinia } from 'pinia'
|
||||||
import { createTestingPinia } from '@pinia/testing'
|
import { createTestingPinia } from '@pinia/testing'
|
||||||
|
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
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'
|
import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js'
|
||||||
|
|
||||||
describe('NotificationUtils', () => {
|
describe('NotificationUtils', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const store = useSyncConfigStore(createTestingPinia())
|
setActivePinia(createTestingPinia())
|
||||||
store.mergedConfig = {
|
useSyncConfigStore().mergedConfig = {
|
||||||
notificationVisibility: {
|
notificationVisibility: {
|
||||||
likes: true,
|
likes: true,
|
||||||
repeats: true,
|
repeats: true,
|
||||||
|
|
@ -16,31 +18,26 @@ describe('NotificationUtils', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('filteredNotificationsFromStore', () => {
|
describe('filteredNotifications', () => {
|
||||||
it('should return sorted notifications with configured types', () => {
|
it('should return sorted notifications with configured types', () => {
|
||||||
const store = {
|
useNotificationsStore().data = [
|
||||||
state: {
|
{
|
||||||
notifications: {
|
id: 1,
|
||||||
data: [
|
action: { id: '1' },
|
||||||
{
|
type: 'like',
|
||||||
id: 1,
|
|
||||||
action: { id: '1' },
|
|
||||||
type: 'like',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
action: { id: '2' },
|
|
||||||
type: 'mention',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
action: { id: '3' },
|
|
||||||
type: 'repeat',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
|
id: 2,
|
||||||
|
action: { id: '2' },
|
||||||
|
type: 'mention',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
action: { id: '3' },
|
||||||
|
type: 'repeat',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
{
|
{
|
||||||
action: { id: '3' },
|
action: { id: '3' },
|
||||||
|
|
@ -54,7 +51,7 @@ describe('NotificationUtils', () => {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(
|
expect(
|
||||||
NotificationUtils.filteredNotificationsFromStore(store, {
|
NotificationUtils.filteredNotifications({
|
||||||
mentions: false,
|
mentions: false,
|
||||||
likes: true,
|
likes: true,
|
||||||
repeats: true,
|
repeats: true,
|
||||||
|
|
@ -63,26 +60,21 @@ describe('NotificationUtils', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('unseenNotificationsFromStore', () => {
|
describe('unseenNotifications', () => {
|
||||||
it('should return only notifications not marked as seen', () => {
|
it('should return only notifications not marked as seen', () => {
|
||||||
const store = {
|
useNotificationsStore().data = [
|
||||||
state: {
|
{
|
||||||
notifications: {
|
action: { id: '1' },
|
||||||
data: [
|
type: 'like',
|
||||||
{
|
seen: false,
|
||||||
action: { id: '1' },
|
|
||||||
type: 'like',
|
|
||||||
seen: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
action: { id: '2' },
|
|
||||||
type: 'mention',
|
|
||||||
seen: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
|
action: { id: '2' },
|
||||||
|
type: 'mention',
|
||||||
|
seen: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
{
|
{
|
||||||
action: { id: '1' },
|
action: { id: '1' },
|
||||||
|
|
@ -91,7 +83,7 @@ describe('NotificationUtils', () => {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(
|
expect(
|
||||||
NotificationUtils.unseenNotificationsFromStore(store, {
|
NotificationUtils.unseenNotifications({
|
||||||
likes: true,
|
likes: true,
|
||||||
repeats: true,
|
repeats: true,
|
||||||
mentions: false,
|
mentions: false,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { createTestingPinia } from '@pinia/testing'
|
import { createTestingPinia } from '@pinia/testing'
|
||||||
import { setActivePinia } from 'pinia'
|
import { setActivePinia } from 'pinia'
|
||||||
|
|
||||||
import { useNotificationsStore } from 'src/stores/notifications.js'
|
|
||||||
import { useStatusesStore } from 'src/stores/statuses.js'
|
|
||||||
import { useUsersStore } from 'src/stores/users.js'
|
|
||||||
import { useReportsStore } from 'src/stores/reports.js'
|
|
||||||
import { useStreamingStore } from 'src/stores/streaming.js'
|
|
||||||
import { useI18nStore } from 'src/stores/i18n.js'
|
import { useI18nStore } from 'src/stores/i18n.js'
|
||||||
|
import { useNotificationsStore } from 'src/stores/notifications.js'
|
||||||
|
import { useReportsStore } from 'src/stores/reports.js'
|
||||||
|
import { useStatusesStore } from 'src/stores/statuses.js'
|
||||||
|
import { useStreamingStore } from 'src/stores/streaming.js'
|
||||||
|
import { useUsersStore } from 'src/stores/users.js'
|
||||||
|
|
||||||
import * as USER_API from 'src/api/user.js'
|
import * as USER_API from 'src/api/user.js'
|
||||||
|
|
||||||
|
|
@ -97,7 +97,11 @@ describe('Notifications store', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.useFakeTimers()
|
vi.useFakeTimers()
|
||||||
setActivePinia(createTestingPinia({ stubActions: false }))
|
setActivePinia(createTestingPinia({ stubActions: false }))
|
||||||
useI18nStore().i18n = { t: () => { /* no-op */} }
|
useI18nStore().i18n = {
|
||||||
|
t: () => {
|
||||||
|
/* no-op */
|
||||||
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
@ -209,13 +213,16 @@ describe('Notifications store', () => {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
store.addNewNotifications({
|
store.addNewNotifications(
|
||||||
timestamp: 1,
|
{
|
||||||
data: [
|
timestamp: 1,
|
||||||
mockStatusNotification({ id: '2' }),
|
data: [
|
||||||
mockStatusNotification({ id: '1' }),
|
mockStatusNotification({ id: '2' }),
|
||||||
],
|
mockStatusNotification({ id: '1' }),
|
||||||
}, true)
|
],
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
|
||||||
// must be ordered
|
// must be ordered
|
||||||
expect(store.data.map(({ id }) => id)).to.eql(['4', '3', '2', '1'])
|
expect(store.data.map(({ id }) => id)).to.eql(['4', '3', '2', '1'])
|
||||||
|
|
@ -236,13 +243,17 @@ describe('Notifications store', () => {
|
||||||
|
|
||||||
expect(mock).to.have.been.called
|
expect(mock).to.have.been.called
|
||||||
expect(mock.mock.calls[0][0]).to.have.property('timestamp', 1337)
|
expect(mock.mock.calls[0][0]).to.have.property('timestamp', 1337)
|
||||||
expect(mock.mock.calls[0][0].data[0]).to.eql(mockedNotification.from_profile)
|
expect(mock.mock.calls[0][0].data[0]).to.eql(
|
||||||
|
mockedNotification.from_profile,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should update reportsStore', (notificationType) => {
|
it('should update reportsStore', (notificationType) => {
|
||||||
const store = useNotificationsStore()
|
const store = useNotificationsStore()
|
||||||
const mock = vi.spyOn(useReportsStore(), 'addReport')
|
const mock = vi.spyOn(useReportsStore(), 'addReport')
|
||||||
const mockedNotification = mockStatusNotification({ type: 'pleroma:report' })
|
const mockedNotification = mockStatusNotification({
|
||||||
|
type: 'pleroma:report',
|
||||||
|
})
|
||||||
mockedNotification.report = { data: '123' }
|
mockedNotification.report = { data: '123' }
|
||||||
|
|
||||||
store.addNewNotifications({
|
store.addNewNotifications({
|
||||||
|
|
@ -264,7 +275,9 @@ describe('Notifications store', () => {
|
||||||
const store = useNotificationsStore()
|
const store = useNotificationsStore()
|
||||||
const mock = vi.fn()
|
const mock = vi.fn()
|
||||||
useStatusesStore().addNewStatuses = mock
|
useStatusesStore().addNewStatuses = mock
|
||||||
const mockedNotification = mockStatusNotification({ type: notificationType })
|
const mockedNotification = mockStatusNotification({
|
||||||
|
type: notificationType,
|
||||||
|
})
|
||||||
|
|
||||||
store.addNewNotifications({
|
store.addNewNotifications({
|
||||||
timestamp: 1337,
|
timestamp: 1337,
|
||||||
|
|
@ -273,7 +286,9 @@ describe('Notifications store', () => {
|
||||||
|
|
||||||
expect(mock).to.have.been.called
|
expect(mock).to.have.been.called
|
||||||
expect(mock.mock.calls[0][0]).to.have.property('timestamp', 1337)
|
expect(mock.mock.calls[0][0]).to.have.property('timestamp', 1337)
|
||||||
expect(mock.mock.calls[0][0].statuses[0]).to.eql(mockedNotification.status)
|
expect(mock.mock.calls[0][0].statuses[0]).to.eql(
|
||||||
|
mockedNotification.status,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -284,8 +299,14 @@ describe('Notifications store', () => {
|
||||||
store.addNewNotifications({
|
store.addNewNotifications({
|
||||||
timestamp: 1,
|
timestamp: 1,
|
||||||
data: [
|
data: [
|
||||||
mockStatusNotification({ id: 'n2', status: mockStatus({ id: 's2' }) }),
|
mockStatusNotification({
|
||||||
mockStatusNotification({ id: 'n1', status: mockStatus({ id: 's1' }) }),
|
id: 'n2',
|
||||||
|
status: mockStatus({ id: 's2' }),
|
||||||
|
}),
|
||||||
|
mockStatusNotification({
|
||||||
|
id: 'n1',
|
||||||
|
status: mockStatus({ id: 's1' }),
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue