routes.spec.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import routes from 'src/boot/routes'
  2. import { createRouter, createMemoryHistory } from 'vue-router'
  3. import { createStore } from 'vuex'
  4. const store = createStore({
  5. state: {
  6. instance: {}
  7. }
  8. })
  9. describe('routes', () => {
  10. const router = createRouter({
  11. history: createMemoryHistory(),
  12. routes: routes(store)
  13. })
  14. it('root path', async () => {
  15. await router.push('/main/all')
  16. const matchedComponents = router.currentRoute.value.matched
  17. // eslint-disable-next-line no-prototype-builtins
  18. expect(matchedComponents[0].components.default.components.hasOwnProperty('Timeline')).to.eql(true)
  19. })
  20. it('user\'s profile', async () => {
  21. await router.push('/fake-user-name')
  22. const matchedComponents = router.currentRoute.value.matched
  23. // eslint-disable-next-line no-prototype-builtins
  24. expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
  25. })
  26. it('user\'s profile at /users', async () => {
  27. await router.push('/users/fake-user-name')
  28. const matchedComponents = router.currentRoute.value.matched
  29. // eslint-disable-next-line no-prototype-builtins
  30. expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
  31. })
  32. })