routes.spec.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import Vuex from 'vuex'
  2. import routes from 'src/boot/routes'
  3. import { createLocalVue } from '@vue/test-utils'
  4. import VueRouter from 'vue-router'
  5. const localVue = createLocalVue()
  6. localVue.use(Vuex)
  7. localVue.use(VueRouter)
  8. const store = new Vuex.Store({
  9. state: {
  10. instance: {}
  11. }
  12. })
  13. describe('routes', () => {
  14. const router = new VueRouter({
  15. mode: 'abstract',
  16. routes: routes(store)
  17. })
  18. it('root path', () => {
  19. router.push('/main/all')
  20. const matchedComponents = router.getMatchedComponents()
  21. expect(matchedComponents[0].components.hasOwnProperty('Timeline')).to.eql(true)
  22. })
  23. it('user\'s profile', () => {
  24. router.push('/fake-user-name')
  25. const matchedComponents = router.getMatchedComponents()
  26. expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
  27. })
  28. it('user\'s profile at /users', () => {
  29. router.push('/users/fake-user-name')
  30. const matchedComponents = router.getMatchedComponents()
  31. expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
  32. })
  33. })