@@ -4,6 +4,7 @@ import VueRouter from 'vue-router'
4
4
import { createLocalVue } from 'packages/test-utils/src'
5
5
import Component from '~resources/components/component.vue'
6
6
import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
7
+ import ComponentWithRouter from '~resources/components/component-with-router.vue'
7
8
import ComponentWithSyncError from '~resources/components/component-with-sync-error.vue'
8
9
import ComponentWithAsyncError from '~resources/components/component-with-async-error.vue'
9
10
import { describeWithShallowAndMount , vueVersion } from '~resources/utils'
@@ -65,6 +66,37 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
65
66
expect ( typeof freshWrapper . vm . $route ) . toEqual ( 'undefined' )
66
67
} )
67
68
69
+ it ( 'works with VueRouter' , async ( ) => {
70
+ if ( mountingMethod . name === 'shallowMount' ) {
71
+ return
72
+ }
73
+ const localVue = createLocalVue ( )
74
+ localVue . use ( VueRouter )
75
+ const Foo = {
76
+ name : 'Foo' ,
77
+ render : h => h ( 'span' , 'Foo component' )
78
+ }
79
+ const routes = [ { path : '/foo' , component : Foo } ]
80
+ const router = new VueRouter ( {
81
+ routes
82
+ } )
83
+ const wrapper = mountingMethod ( ComponentWithRouter , {
84
+ localVue,
85
+ router
86
+ } )
87
+
88
+ expect ( wrapper . html ( ) ) . not . toContain ( 'Foo component' )
89
+ expect ( wrapper . vm . $route ) . toBeTruthy ( )
90
+
91
+ await wrapper . vm . $router . push ( '/foo' )
92
+ expect ( wrapper . html ( ) ) . toContain ( 'Foo component' )
93
+
94
+ await wrapper . vm . $router . push ( '/' )
95
+ expect ( wrapper . html ( ) ) . not . toContain ( 'Foo component' )
96
+ await wrapper . find ( 'a' ) . trigger ( 'click' )
97
+ expect ( wrapper . html ( ) ) . toContain ( 'Foo component' )
98
+ } )
99
+
68
100
it ( 'use can take additional arguments' , ( ) => {
69
101
const localVue = createLocalVue ( )
70
102
const pluginOptions = { foo : 'bar' }
0 commit comments