forked from ModusCreateOrg/ionic-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.spec.js
45 lines (36 loc) · 1.04 KB
/
router.spec.js
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
import Vue from 'vue'
import Router from '../src/router.js'
describe('Router', () => {
it('Installs correctly', () => {
Vue.use(Router)
const app = new Vue({
router: new Router(),
})
expect(typeof app.$router).toBe('object')
expect(typeof app.$options.components.IonVueRouter).toBe('function')
expect(Router.install()).toBeFalsy()
})
it('Navigates correctly', () => {
const r = new Router({ mode: 'abstract' })
r.push('/')
expect(r.viewCount).toBe(1)
expect(r.direction).toBe(1)
expect(r.canGoBack()).toBeFalsy()
r.push('/foo')
expect(r.viewCount).toBe(2)
expect(r.direction).toBe(1)
expect(r.canGoBack()).toBeTruthy()
r.push('/bar')
expect(r.viewCount).toBe(3)
expect(r.direction).toBe(1)
expect(r.canGoBack()).toBeTruthy()
r.go(-1)
expect(r.viewCount).toBe(2)
expect(r.direction).toBe(-1)
expect(r.canGoBack()).toBeTruthy()
r.go(-1)
expect(r.viewCount).toBe(1)
expect(r.direction).toBe(-1)
expect(r.canGoBack()).toBeFalsy()
})
})