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

68 行
2.0 KiB
JavaScript
Raw 通常表示 履歴

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