@@ -8,7 +8,7 @@ import ComponentWithVFor from '~resources/components/component-with-v-for.vue'
8
8
import Component from '~resources/components/component.vue'
9
9
import FunctionalComponent from '~resources/components/functional-component.vue'
10
10
import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
11
- import { functionalSFCsSupported } from '~resources/test-utils'
11
+ import { functionalSFCsSupported , vueVersion } from '~resources/test-utils'
12
12
13
13
describe ( 'find' , ( ) => {
14
14
it ( 'returns a Wrapper matching tag selector passed' , ( ) => {
@@ -141,6 +141,28 @@ describe('find', () => {
141
141
expect ( wrapper . find ( FunctionalComponent ) . vm ) . to . equal ( undefined )
142
142
} )
143
143
144
+ it ( 'returns Wrapper of Vue Component matching functional component with name' , ( ) => {
145
+ const TestFunctionalComponent = {
146
+ render : h => h ( 'div' ) ,
147
+ functional : true ,
148
+ name : 'test-functional-component'
149
+ }
150
+ const TestComponent = {
151
+ template : '<div><test-functional-component /></div>' ,
152
+ components : {
153
+ TestFunctionalComponent
154
+ }
155
+ }
156
+ const wrapper = mount ( TestComponent )
157
+ if ( vueVersion < 2.3 ) {
158
+ const message = '[vue-test-utils]: find for functional components is not support in Vue < 2.3'
159
+ const fn = ( ) => wrapper . find ( TestFunctionalComponent )
160
+ expect ( fn ) . to . throw ( ) . with . property ( 'message' , message )
161
+ } else {
162
+ expect ( wrapper . find ( TestFunctionalComponent ) . exists ( ) ) . to . equal ( true )
163
+ }
164
+ } )
165
+
144
166
it ( 'returns correct number of Vue Wrappers when component has a v-for' , ( ) => {
145
167
const items = [ { id : 1 } , { id : 2 } , { id : 3 } ]
146
168
const wrapper = mount ( ComponentWithVFor , { propsData : { items } } )
0 commit comments