forked from vuejs/vue-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactory.spec.js
50 lines (41 loc) · 1.12 KB
/
factory.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
46
47
48
49
import Router from '../../../src/index'
import Vue from 'vue'
describe('router factory', () => {
let InstancedBasedApp, FactoryBasedApp
beforeEach(() => {
const routerFactory = () => new Router({
mode: 'abstract',
routes: [
{
path: '/a',
component: {
name: 'A'
}
}
]
})
const router = routerFactory()
InstancedBasedApp = Vue.extend({
router,
render (h) { return h('div') }
})
FactoryBasedApp = Vue.extend({
router: routerFactory,
render (h) { return h('div') }
})
})
it('should initialize router from factory', () => {
const vm = new FactoryBasedApp()
expect(vm.$router instanceof Router).toBeTruthy()
})
it('should use different router instances on different app instances', () => {
const app = new FactoryBasedApp()
const app2 = new FactoryBasedApp()
expect(app.$router).not.toBe(app2.$router)
})
it('should allow to work as normal', () => {
const app = new InstancedBasedApp()
const app2 = new InstancedBasedApp()
expect(app.$router).toBe(app2.$router)
})
})