routes.spec.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. expect(matchedComponents[0].components.default.components.hasOwnProperty('Timeline')).to.eql(true)
  18. })
  19. it('user\'s profile', async () => {
  20. await router.push('/fake-user-name')
  21. const matchedComponents = router.currentRoute.value.matched
  22. expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
  23. })
  24. it('user\'s profile at /users', async () => {
  25. await router.push('/users/fake-user-name')
  26. const matchedComponents = router.currentRoute.value.matched
  27. expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
  28. })
  29. })