@@ -602,17 +602,18 @@ describeWithMountingMethods('options.slots', mountingMethod => {
602
602
603
603
itDoNotRunIf (
604
604
mountingMethod . name === 'renderToString' ,
605
- 'sets a component which can access the parent component' ,
605
+ 'sets a component which can access the parent component and the child component ' ,
606
606
( ) => {
607
607
const localVue = createLocalVue ( )
608
608
localVue . prototype . bar = 'FOO'
609
- const wrapperComponent = mount (
609
+ const ParentComponent = mount (
610
610
{
611
611
name : 'parentComponent' ,
612
612
template : '<div><slot /></div>' ,
613
613
data ( ) {
614
614
return {
615
- childName : ''
615
+ time : 1 ,
616
+ childComponentName : ''
616
617
}
617
618
}
618
619
} ,
@@ -621,13 +622,24 @@ describeWithMountingMethods('options.slots', mountingMethod => {
621
622
ComponentWithParentName
622
623
} ,
623
624
slots : {
624
- default : '<component-with-parent-name :foo="bar" />'
625
+ default : [
626
+ '<component-with-parent-name :fromLocalVue="bar" :time="time" />' ,
627
+ '<component-with-parent-name :fromLocalVue="bar" :time="time" />'
628
+ ]
625
629
} ,
626
630
localVue
627
631
}
628
632
)
629
- expect ( wrapperComponent . vm . childName ) . to . equal ( 'component-with-parent-name' )
630
- expect ( wrapperComponent . html ( ) ) . to . equal ( '<div><div foo="FOO"><span baz="qux">quux</span></div></div>' )
633
+ const childComponentName = 'component-with-parent-name'
634
+ expect ( ParentComponent . vm . childComponentName ) . to . equal ( childComponentName )
635
+ expect ( ParentComponent . vm . $children . length ) . to . equal ( 2 )
636
+ expect ( ParentComponent . vm . $children . every ( c => c . $options . name === childComponentName ) ) . to . equal ( true )
637
+ expect ( ParentComponent . html ( ) ) . to . equal ( '<div><div><span baz="qux">1,FOO,quux</span></div><div><span baz="qux">1,FOO,quux</span></div></div>' )
638
+ ParentComponent . vm . time = 2
639
+ expect ( ParentComponent . vm . childComponentName ) . to . equal ( childComponentName )
640
+ expect ( ParentComponent . vm . $children . length ) . to . equal ( 2 )
641
+ expect ( ParentComponent . vm . $children . every ( c => c . $options . name === childComponentName ) ) . to . equal ( true )
642
+ expect ( ParentComponent . html ( ) ) . to . equal ( '<div><div><span baz="qux">2,FOO,quux</span></div><div><span baz="qux">2,FOO,quux</span></div></div>' )
631
643
}
632
644
)
633
645
} )
0 commit comments