pleroma-fe/test/unit/specs/boot/routes.spec.js

95 lines
2 KiB
JavaScript
Raw Normal View History

2026-01-06 16:23:17 +02:00
import { createMemoryHistory, createRouter } from 'vue-router'
2022-03-22 18:56:54 +02:00
import { createStore } from 'vuex'
2026-01-08 17:26:52 +02:00
import routes from 'src/boot/routes'
2022-03-22 18:56:54 +02:00
const store = createStore({
2020-05-07 16:10:53 +03:00
state: {
2026-01-06 16:22:52 +02:00
instance: {},
},
2020-05-07 16:10:53 +03:00
})
describe('routes', () => {
2022-03-22 18:56:54 +02:00
const router = createRouter({
history: createMemoryHistory(),
2026-01-06 16:22:52 +02:00
routes: routes(store),
})
2022-03-22 18:56:54 +02:00
it('root path', async () => {
await router.push('/main/all')
2022-03-22 18:56:54 +02:00
const matchedComponents = router.currentRoute.value.matched
2026-01-06 16:22:52 +02:00
expect(
Object.hasOwn(
matchedComponents[0].components.default.components,
'Timeline',
),
).to.eql(true)
})
2026-01-06 16:22:52 +02:00
it("user's profile", async () => {
2022-03-22 18:56:54 +02:00
await router.push('/fake-user-name')
2022-03-22 18:56:54 +02:00
const matchedComponents = router.currentRoute.value.matched
2026-01-06 16:22:52 +02:00
expect(
Object.hasOwn(
matchedComponents[0].components.default.components,
'UserCard',
),
).to.eql(true)
})
2026-01-06 16:22:52 +02:00
it("user's profile at /users", async () => {
2022-03-22 18:56:54 +02:00
await router.push('/users/fake-user-name')
2022-03-22 18:56:54 +02:00
const matchedComponents = router.currentRoute.value.matched
2026-01-06 16:22:52 +02:00
expect(
Object.hasOwn(
matchedComponents[0].components.default.components,
'UserCard',
),
).to.eql(true)
})
2022-08-06 17:26:43 +03:00
it('list view', async () => {
await router.push('/lists')
const matchedComponents = router.currentRoute.value.matched
2026-01-06 16:22:52 +02:00
expect(
Object.hasOwn(
matchedComponents[0].components.default.components,
'ListsCard',
),
).to.eql(true)
2022-08-06 17:26:43 +03:00
})
it('list timeline', async () => {
await router.push('/lists/1')
const matchedComponents = router.currentRoute.value.matched
2026-01-06 16:22:52 +02:00
expect(
Object.hasOwn(
matchedComponents[0].components.default.components,
'Timeline',
),
).to.eql(true)
2022-08-06 17:26:43 +03:00
})
it('list edit', async () => {
await router.push('/lists/1/edit')
const matchedComponents = router.currentRoute.value.matched
2026-01-06 16:22:52 +02:00
expect(
Object.hasOwn(
matchedComponents[0].components.default.components,
'BasicUserCard',
),
).to.eql(true)
2022-08-06 17:26:43 +03:00
})
})