routes.spec.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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: { private: false },
  11. users: {}
  12. }
  13. })
  14. describe('routes', () => {
  15. const router = new VueRouter({
  16. mode: 'abstract',
  17. routes: routes(store)
  18. })
  19. it('root path', () => {
  20. router.push('/main/all')
  21. const matchedComponents = router.getMatchedComponents()
  22. expect(matchedComponents[0].components.hasOwnProperty('Timeline')).to.eql(true)
  23. })
  24. it('user\'s profile', () => {
  25. router.push('/fake-user-name')
  26. const matchedComponents = router.getMatchedComponents()
  27. expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
  28. })
  29. it('user\'s profile at /users', () => {
  30. router.push('/users/fake-user-name')
  31. const matchedComponents = router.getMatchedComponents()
  32. expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
  33. })
  34. })