Skip to content

Commit fa0322b

Browse files
committed
chore: simplify flaky test
1 parent aeb5fd6 commit fa0322b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/specs/create-local-vue.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import VueRouter from 'vue-router'
44
import { createLocalVue } from 'packages/test-utils/src'
55
import Component from '~resources/components/component.vue'
66
import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
7+
import ComponentWithRouter from '~resources/components/component-with-router.vue'
78
import ComponentWithSyncError from '~resources/components/component-with-sync-error.vue'
89
import ComponentWithAsyncError from '~resources/components/component-with-async-error.vue'
910
import { describeWithShallowAndMount, vueVersion } from '~resources/utils'
@@ -65,6 +66,37 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
6566
expect(typeof freshWrapper.vm.$route).toEqual('undefined')
6667
})
6768

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+
68100
it('use can take additional arguments', () => {
69101
const localVue = createLocalVue()
70102
const pluginOptions = { foo: 'bar' }

0 commit comments

Comments
 (0)