fix routes test

This commit is contained in:
Henry Jameson 2022-03-22 18:56:54 +02:00
parent e5ae0671ce
commit 3250e59266
1 changed files with 17 additions and 22 deletions

View File

@ -1,45 +1,40 @@
import Vuex from 'vuex'
import routes from 'src/boot/routes' import routes from 'src/boot/routes'
import { createLocalVue } from '@vue/test-utils' import { createRouter, createMemoryHistory } from 'vue-router'
import VueRouter from 'vue-router' import { createStore } from 'vuex'
const localVue = createLocalVue() const store = createStore({
localVue.use(Vuex)
localVue.use(VueRouter)
const store = new Vuex.Store({
state: { state: {
instance: {} instance: {}
} }
}) })
describe('routes', () => { describe('routes', () => {
const router = new VueRouter({ const router = createRouter({
mode: 'abstract', history: createMemoryHistory(),
routes: routes(store) routes: routes(store)
}) })
it('root path', () => { it('root path', async () => {
router.push('/main/all') await router.push('/main/all')
const matchedComponents = router.getMatchedComponents() const matchedComponents = router.currentRoute.value.matched
expect(matchedComponents[0].components.hasOwnProperty('Timeline')).to.eql(true) expect(matchedComponents[0].components.default.components.hasOwnProperty('Timeline')).to.eql(true)
}) })
it('user\'s profile', () => { it('user\'s profile', async () => {
router.push('/fake-user-name') await router.push('/fake-user-name')
const matchedComponents = router.getMatchedComponents() const matchedComponents = router.currentRoute.value.matched
expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true) expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
}) })
it('user\'s profile at /users', () => { it('user\'s profile at /users', async () => {
router.push('/users/fake-user-name') await router.push('/users/fake-user-name')
const matchedComponents = router.getMatchedComponents() const matchedComponents = router.currentRoute.value.matched
expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true) expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
}) })
}) })