@@ -2,6 +2,7 @@ import { compileToFunctions } from 'vue-template-compiler'
2
2
import mount from '~src/mount'
3
3
import Component from '~resources/components/component.vue'
4
4
import ComponentWithSlots from '~resources/components/component-with-slots.vue'
5
+ import { vueVersion } from '~resources/test-utils'
5
6
6
7
describe ( 'mount.slots' , ( ) => {
7
8
it ( 'mounts component with default slot if passed component in slot object' , ( ) => {
@@ -25,6 +26,17 @@ describe('mount.slots', () => {
25
26
expect ( wrapper . contains ( 'span' ) ) . to . equal ( true )
26
27
} )
27
28
29
+ it ( 'mounts component with default slot if passed string in slot object' , ( ) => {
30
+ if ( vueVersion >= 2.2 ) {
31
+ const wrapper = mount ( ComponentWithSlots , { slots : { default : 'foo' } } )
32
+ expect ( wrapper . find ( 'main' ) . text ( ) ) . to . equal ( 'foo' )
33
+ } else {
34
+ const message = '[vue-test-utils]: vue-test-utils support for passing text to slots at [email protected] +'
35
+ const fn = ( ) => mount ( ComponentWithSlots , { slots : { default : 'foo' } } )
36
+ expect ( fn ) . to . throw ( ) . with . property ( 'message' , message )
37
+ }
38
+ } )
39
+
28
40
it ( 'throws error if passed string in default slot object and vue-template-compiler is undefined' , ( ) => {
29
41
const compilerSave = require . cache [ require . resolve ( 'vue-template-compiler' ) ] . exports . compileToFunctions
30
42
require . cache [ require . resolve ( 'vue-template-compiler' ) ] . exports . compileToFunctions = undefined
@@ -46,6 +58,17 @@ describe('mount.slots', () => {
46
58
expect ( wrapper . contains ( 'span' ) ) . to . equal ( true )
47
59
} )
48
60
61
+ it ( 'mounts component with default slot if passed string in slot text array object' , ( ) => {
62
+ if ( vueVersion >= 2.2 ) {
63
+ const wrapper = mount ( ComponentWithSlots , { slots : { default : [ 'foo' , 'bar' ] } } )
64
+ expect ( wrapper . find ( 'main' ) . text ( ) ) . to . equal ( 'foobar' )
65
+ } else {
66
+ const message = '[vue-test-utils]: vue-test-utils support for passing text to slots at [email protected] +'
67
+ const fn = ( ) => mount ( ComponentWithSlots , { slots : { default : [ 'foo' , 'bar' ] } } )
68
+ expect ( fn ) . to . throw ( ) . with . property ( 'message' , message )
69
+ }
70
+ } )
71
+
49
72
it ( 'throws error if passed string in default slot array vue-template-compiler is undefined' , ( ) => {
50
73
const compilerSave = require . cache [ require . resolve ( 'vue-template-compiler' ) ] . exports . compileToFunctions
51
74
require . cache [ require . resolve ( 'vue-template-compiler' ) ] . exports . compileToFunctions = undefined
0 commit comments