aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/boot/routes.spec.js
blob: 4c3875670a3e91b0ca7daf3e73deb400b97acea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import routes from 'src/boot/routes'
import { createRouter, createMemoryHistory } from 'vue-router'
import { createStore } from 'vuex'

const store = createStore({
  state: {
    instance: {}
  }
})

describe('routes', () => {
  const router = createRouter({
    history: createMemoryHistory(),
    routes: routes(store)
  })

  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.currentRoute.value.matched

    expect(matchedComponents[0].components.default.components.hasOwnProperty('ListsCard')).to.eql(true)
  })

  it('list timeline', async () => {
    await router.push('/lists/1')

    const matchedComponents = router.currentRoute.value.matched

    expect(matchedComponents[0].components.default.components.hasOwnProperty('Timeline')).to.eql(true)
  })

  it('list edit', async () => {
    await router.push('/lists/1/edit')

    const matchedComponents = router.currentRoute.value.matched

    expect(matchedComponents[0].components.default.components.hasOwnProperty('BasicUserCard')).to.eql(true)
  })
})