@@ -19,17 +19,25 @@ describeWithShallowAndMount('scopedSlots', (mountingMethod) => {
19
19
const wrapper = mountingMethod ( ComponentWithScopedSlots , {
20
20
slots : { default : '<span>123</span>' } ,
21
21
scopedSlots : {
22
- 'foo' : '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>' ,
23
- 'bar' : '<p slot-scope="bar">{{bar.text}},{{bar.index}}</p>'
22
+ destructuring : '<p slot-scope="{ index, item }">{{index}},{{item}}</p>' ,
23
+ list : '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>' ,
24
+ single : '<p slot-scope="bar">{{bar.text}}</p>' ,
25
+ noProps : '<p slot-scope="baz">baz</p>'
24
26
}
25
27
} )
28
+ expect ( wrapper . find ( '#destructuring' ) . html ( ) ) . to . equal ( '<div id="destructuring"><p>0,1</p><p>1,2</p><p>2,3</p></div>' )
26
29
expect ( wrapper . find ( '#slots' ) . html ( ) ) . to . equal ( '<div id="slots"><span>123</span></div>' )
27
- expect ( wrapper . find ( '#foo' ) . html ( ) ) . to . equal ( '<div id="foo"><p>0,a1</p><p>1,a2</p><p>2,a3</p></div>' )
28
- expect ( wrapper . find ( '#bar' ) . html ( ) ) . to . equal ( '<div id="bar"><p>A1,0</p><p>A2,1</p><p>A3,2</p></div>' )
30
+ expect ( wrapper . find ( '#list' ) . html ( ) ) . to . equal ( '<div id="list"><p>0,a1</p><p>1,a2</p><p>2,a3</p></div>' )
31
+ expect ( wrapper . find ( '#single' ) . html ( ) ) . to . equal ( '<div id="single"><p>abc</p></div>' )
32
+ expect ( wrapper . find ( '#noProps' ) . html ( ) ) . to . equal ( '<div id="noProps"><p>baz</p></div>' )
33
+ wrapper . vm . items = [ 4 , 5 , 6 ]
29
34
wrapper . vm . foo = [ { text : 'b1' } , { text : 'b2' } , { text : 'b3' } ]
30
- wrapper . vm . bar = [ { text : 'B1' } , { text : 'B2' } , { text : 'B3' } ]
31
- expect ( wrapper . find ( '#foo' ) . html ( ) ) . to . equal ( '<div id="foo"><p>0,b1</p><p>1,b2</p><p>2,b3</p></div>' )
32
- expect ( wrapper . find ( '#bar' ) . html ( ) ) . to . equal ( '<div id="bar"><p>B1,0</p><p>B2,1</p><p>B3,2</p></div>' )
35
+ wrapper . vm . bar = 'ABC'
36
+ expect ( wrapper . find ( '#destructuring' ) . html ( ) ) . to . equal ( '<div id="destructuring"><p>0,4</p><p>1,5</p><p>2,6</p></div>' )
37
+ expect ( wrapper . find ( '#slots' ) . html ( ) ) . to . equal ( '<div id="slots"><span>123</span></div>' )
38
+ expect ( wrapper . find ( '#list' ) . html ( ) ) . to . equal ( '<div id="list"><p>0,b1</p><p>1,b2</p><p>2,b3</p></div>' )
39
+ expect ( wrapper . find ( '#single' ) . html ( ) ) . to . equal ( '<div id="single"><p>ABC</p></div>' )
40
+ expect ( wrapper . find ( '#noProps' ) . html ( ) ) . to . equal ( '<div id="noProps"><p>baz</p></div>' )
33
41
}
34
42
)
35
43
@@ -38,7 +46,7 @@ describeWithShallowAndMount('scopedSlots', (mountingMethod) => {
38
46
const fn = ( ) => {
39
47
mountingMethod ( ComponentWithScopedSlots , {
40
48
scopedSlots : {
41
- 'foo' : '<template></template>'
49
+ single : '<template></template>'
42
50
}
43
51
} )
44
52
}
@@ -52,7 +60,7 @@ describeWithShallowAndMount('scopedSlots', (mountingMethod) => {
52
60
const fn = ( ) => {
53
61
mountingMethod ( ComponentWithScopedSlots , {
54
62
scopedSlots : {
55
- 'foo' : '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>'
63
+ list : '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>'
56
64
}
57
65
} )
58
66
}
@@ -70,7 +78,7 @@ describeWithShallowAndMount('scopedSlots', (mountingMethod) => {
70
78
const fn = ( ) => {
71
79
mountingMethod ( ComponentWithScopedSlots , {
72
80
scopedSlots : {
73
- 'foo' : '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>'
81
+ list : '<p slot-scope="foo">{{foo.index}},{{foo.text}}</p>'
74
82
}
75
83
} )
76
84
}
0 commit comments