11import { compileToFunctions } from 'vue-template-compiler'
2- import { createLocalVue } from 'packages/test-utils/src'
2+ import { createLocalVue , shallowMount } from 'packages/test-utils/src'
33import Vue from 'vue'
4+ import VueRouter from 'vue-router'
45import ComponentWithChild from '~resources/components/component-with-child.vue'
56import ComponentWithoutName from '~resources/components/component-without-name.vue'
67import ComponentWithSlots from '~resources/components/component-with-slots.vue'
@@ -17,6 +18,58 @@ import {
1718import { itDoNotRunIf , itSkipIf } from 'conditional-specs'
1819
1920describeWithShallowAndMount ( 'find' , mountingMethod => {
21+ itDoNotRunIf (
22+ mountingMethod . name === 'shallowMount' ,
23+ 'returns a VueWrapper using a <router-view /> component' ,
24+ async ( ) => {
25+ const localVue = createLocalVue ( )
26+ localVue . use ( VueRouter )
27+ const TestComponentToFind = {
28+ render : h => h ( 'div' ) ,
29+ name : 'test-component-to-find'
30+ }
31+ const routes = [
32+ {
33+ path : '/a/b' ,
34+ name : 'ab' ,
35+ component : TestComponentToFind
36+ }
37+ ]
38+ const router = new VueRouter ( { routes } )
39+ const wrapper = mountingMethod (
40+ {
41+ template : '<router-view/>'
42+ } ,
43+ {
44+ localVue,
45+ router
46+ }
47+ )
48+
49+ await router . push ( '/a/b' )
50+
51+ expect ( wrapper . findComponent ( TestComponentToFind ) . exists ( ) ) . toBe ( true )
52+ }
53+ )
54+
55+ it ( 'findComponent in functional component' , ( ) => {
56+ const Comp2 = {
57+ name : 'test' ,
58+ render ( h ) {
59+ return h ( 'div' , 'test' )
60+ }
61+ }
62+ const Comp = {
63+ name : 'Comp' ,
64+ functional : true ,
65+ render ( h ) {
66+ return h ( Comp2 )
67+ }
68+ }
69+ const wrapper = shallowMount ( Comp )
70+ wrapper . getComponent ( Comp2 )
71+ } )
72+
2073 it ( 'returns a Wrapper matching tag selector passed' , ( ) => {
2174 const compiled = compileToFunctions ( '<div><p></p><p></p></div>' )
2275 const wrapper = mountingMethod ( compiled )
0 commit comments