@@ -2,19 +2,15 @@ import { compileToFunctions } from 'vue-template-compiler'
22import mount from '~src/mount'
33import Component from '~resources/components/component.vue'
44import ComponentWithSlots from '~resources/components/component-with-slots.vue'
5+ import FunctionalComponentWithSlots from '~resources/components/functional-component-with-slots.vue'
56
67describe ( 'mount.slots' , ( ) => {
78 it ( 'mounts component with default slot if passed component in slot object' , ( ) => {
8- const wrapper = mount ( ComponentWithSlots , { slots : { default : [ Component ] } } )
9- expect ( wrapper . contains ( Component ) ) . to . equal ( true )
10- } )
11-
12- it ( 'mounts component with default slot if passed object with template prop in slot object' , ( ) => {
13- const wrapper = mount ( ComponentWithSlots , { slots : { default : [ Component ] } } )
9+ const wrapper = mount ( ComponentWithSlots , { slots : { default : Component } } )
1410 expect ( wrapper . contains ( Component ) ) . to . equal ( true )
1511 } )
1612
17- it ( 'mounts component with default slot if passed component in slot object' , ( ) => {
13+ it ( 'mounts component with default slot if passed component in array in slot object' , ( ) => {
1814 const wrapper = mount ( ComponentWithSlots , { slots : { default : [ Component ] } } )
1915 expect ( wrapper . contains ( Component ) ) . to . equal ( true )
2016 } )
@@ -86,4 +82,25 @@ describe('mount.slots', () => {
8682 expect ( wrapper . findAll ( Component ) . length ) . to . equal ( 1 )
8783 expect ( Array . isArray ( wrapper . vm . $slots . header ) ) . to . equal ( true )
8884 } )
85+
86+ it . only ( 'mounts functional component with default slot if passed component in slot object' , ( ) => {
87+ const wrapper = mount ( FunctionalComponentWithSlots , { slots : { default : [ Component ] } } )
88+ expect ( wrapper . contains ( Component ) ) . to . equal ( true )
89+ } )
90+
91+ it . only ( 'mounts component with default slot if passed component in slot object' , ( ) => {
92+ const wrapper = mount ( FunctionalComponentWithSlots , { slots : { default : [ Component ] } } )
93+ expect ( wrapper . contains ( Component ) ) . to . equal ( true )
94+ } )
95+
96+ it . only ( 'mounts component with default slot if passed object with template prop in slot object' , ( ) => {
97+ const compiled = compileToFunctions ( '<div id="div" />' )
98+ const wrapper = mount ( FunctionalComponentWithSlots , { slots : { default : [ compiled ] } } )
99+ expect ( wrapper . contains ( '#div' ) ) . to . equal ( true )
100+ } )
101+
102+ it . only ( 'mounts component with default slot if passed string in slot object' , ( ) => {
103+ const wrapper = mount ( FunctionalComponentWithSlots , { slots : { default : '<span />' } } )
104+ expect ( wrapper . contains ( 'span' ) ) . to . equal ( true )
105+ } )
89106} )
0 commit comments