@@ -2,8 +2,10 @@ import { compileToFunctions } from 'vue-template-compiler'
2
2
import Component from '~resources/components/component.vue'
3
3
import ComponentWithSlots from '~resources/components/component-with-slots.vue'
4
4
import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
5
+ import ComponentWithParentName from '~resources/components/component-with-parent-name.vue'
5
6
import { describeWithMountingMethods , vueVersion } from '~resources/utils'
6
7
import { itSkipIf , itDoNotRunIf } from 'conditional-specs'
8
+ import { mount } from '~vue/test-utils'
7
9
8
10
describeWithMountingMethods ( 'options.slots' , mountingMethod => {
9
11
it ( 'mounts component with default slot if passed component in slot object' , ( ) => {
@@ -546,4 +548,28 @@ describeWithMountingMethods('options.slots', mountingMethod => {
546
548
wrapper . find ( 'div' ) . trigger ( 'click' )
547
549
}
548
550
)
551
+
552
+ it ( 'sets a component which can access the parent component' , ( ) => {
553
+ const wrapperComponent = mount (
554
+ {
555
+ name : 'parentComponent' ,
556
+ template : '<div><slot /></div>' ,
557
+ data ( ) {
558
+ return {
559
+ childName : ''
560
+ }
561
+ }
562
+ } ,
563
+ {
564
+ components : {
565
+ ComponentWithParentName
566
+ } ,
567
+ slots : {
568
+ default : '<component-with-parent-name />'
569
+ }
570
+ }
571
+ )
572
+ expect ( wrapperComponent . vm . childName ) . to . equal ( 'component-with-parent-name' )
573
+ expect ( wrapperComponent . html ( ) ) . to . equal ( '<div><div foo="bar"><span baz="qux">quux</span></div></div>' )
574
+ } )
549
575
} )
0 commit comments