aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/boot/routes.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/specs/boot/routes.spec.js')
-rw-r--r--test/unit/specs/boot/routes.spec.js66
1 files changed, 44 insertions, 22 deletions
diff --git a/test/unit/specs/boot/routes.spec.js b/test/unit/specs/boot/routes.spec.js
index 3673256f..ff246d2b 100644
--- a/test/unit/specs/boot/routes.spec.js
+++ b/test/unit/specs/boot/routes.spec.js
@@ -1,45 +1,67 @@
-import Vuex from 'vuex'
import routes from 'src/boot/routes'
-import { createLocalVue } from '@vue/test-utils'
-import VueRouter from 'vue-router'
+import { createRouter, createMemoryHistory } from 'vue-router'
+import { createStore } from 'vuex'
-const localVue = createLocalVue()
-localVue.use(Vuex)
-localVue.use(VueRouter)
-
-const store = new Vuex.Store({
+const store = createStore({
state: {
instance: {}
}
})
describe('routes', () => {
- const router = new VueRouter({
- mode: 'abstract',
+ const router = createRouter({
+ history: createMemoryHistory(),
routes: routes(store)
})
- it('root path', () => {
- router.push('/main/all')
+ it('root path', async () => {
+ await router.push('/main/all')
+
+ const matchedComponents = router.currentRoute.value.matched
+
+ // eslint-disable-next-line no-prototype-builtins
+ expect(matchedComponents[0].components.default.components.hasOwnProperty('Timeline')).to.eql(true)
+ })
+
+ it('user\'s profile', async () => {
+ await router.push('/fake-user-name')
+
+ const matchedComponents = router.currentRoute.value.matched
+
+ // eslint-disable-next-line no-prototype-builtins
+ expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
+ })
+
+ it('user\'s profile at /users', async () => {
+ await router.push('/users/fake-user-name')
+
+ const matchedComponents = router.currentRoute.value.matched
+
+ // eslint-disable-next-line no-prototype-builtins
+ expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
+ })
+
+ it('list view', async () => {
+ await router.push('/lists')
- const matchedComponents = router.getMatchedComponents()
+ const matchedComponents = router.currentRoute.value.matched
- expect(matchedComponents[0].components.hasOwnProperty('Timeline')).to.eql(true)
+ expect(Object.prototype.hasOwnProperty.call(matchedComponents[0].components.default.components, 'ListsCard')).to.eql(true)
})
- it('user\'s profile', () => {
- router.push('/fake-user-name')
+ it('list timeline', async () => {
+ await router.push('/lists/1')
- const matchedComponents = router.getMatchedComponents()
+ const matchedComponents = router.currentRoute.value.matched
- expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
+ expect(Object.prototype.hasOwnProperty.call(matchedComponents[0].components.default.components, 'Timeline')).to.eql(true)
})
- it('user\'s profile at /users', () => {
- router.push('/users/fake-user-name')
+ it('list edit', async () => {
+ await router.push('/lists/1/edit')
- const matchedComponents = router.getMatchedComponents()
+ const matchedComponents = router.currentRoute.value.matched
- expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
+ expect(Object.prototype.hasOwnProperty.call(matchedComponents[0].components.default.components, 'BasicUserCard')).to.eql(true)
})
})