1
1
var Vue = require ( 'src' )
2
- var _ = require ( 'src/util' )
2
+ var nextTick = Vue . nextTick
3
3
4
4
describe ( 'Slot Distribution' , function ( ) {
5
5
@@ -158,7 +158,7 @@ describe('Slot Distribution', function () {
158
158
} )
159
159
expect ( el . innerHTML ) . toBe ( '<test>hello</test>' )
160
160
vm . msg = 'what'
161
- _ . nextTick ( function ( ) {
161
+ nextTick ( function ( ) {
162
162
expect ( el . innerHTML ) . toBe ( '<test>what</test>' )
163
163
done ( )
164
164
} )
@@ -182,14 +182,14 @@ describe('Slot Distribution', function () {
182
182
} )
183
183
expect ( el . textContent ) . toBe ( '12' )
184
184
vm . a = 2
185
- _ . nextTick ( function ( ) {
185
+ nextTick ( function ( ) {
186
186
expect ( el . textContent ) . toBe ( '22' )
187
187
vm . show = false
188
- _ . nextTick ( function ( ) {
188
+ nextTick ( function ( ) {
189
189
expect ( el . textContent ) . toBe ( '' )
190
190
vm . show = true
191
191
vm . a = 3
192
- _ . nextTick ( function ( ) {
192
+ nextTick ( function ( ) {
193
193
8000
expect ( el . textContent ) . toBe ( '32' )
194
194
done ( )
195
195
} )
@@ -237,7 +237,7 @@ describe('Slot Distribution', function () {
237
237
markup = vm . list . map ( function ( item ) {
238
238
return '<div class="child parent">' + item . a + ' ho</div>'
239
239
} ) . join ( '' )
240
- _ . nextTick ( function ( ) {
240
+ nextTick ( function ( ) {
241
241
expect ( el . innerHTML ) . toBe ( markup )
242
242
done ( )
243
243
} )
@@ -266,7 +266,7 @@ describe('Slot Distribution', function () {
266
266
'</testb></testa>'
267
267
)
268
268
vm . list . push ( 3 )
269
- _ . nextTick ( function ( ) {
269
+ nextTick ( function ( ) {
270
270
expect ( el . innerHTML ) . toBe (
271
271
'<testa><testb>' +
272
272
'<div>1</div><div>2</div><div>3</div>' +
@@ -297,7 +297,7 @@ describe('Slot Distribution', function () {
297
297
} )
298
298
expect ( el . innerHTML ) . toBe ( '<testa></testa>' )
299
299
vm . ok = true
300
- _ . nextTick ( function ( ) {
300
+ nextTick ( function ( ) {
301
301
expect ( el . innerHTML ) . toBe ( '<testa><testb>hello</testb></testa>' )
302
302
done ( )
303
303
} )
@@ -397,4 +397,25 @@ describe('Slot Distribution', function () {
397
397
expect ( el . textContent ) . toBe ( 'hihihi' )
398
398
} )
399
399
400
+ it ( 'fallback for slot with v-if' , function ( done ) {
401
+ var vm = new Vue ( {
402
+ el : el ,
403
+ data : {
404
+ ok : false
405
+ } ,
406
+ template : '<div><comp><div v-if="ok">inserted</div></comp></div>' ,
407
+ components : {
408
+ comp : {
409
+ template : '<div><slot>fallback</slot></div>'
410
+ }
411
+ }
412
+ } )
413
+ expect ( el . textContent ) . toBe ( 'fallback' )
414
+ vm . ok = true
415
+ nextTick ( function ( ) {
416
+ expect ( el . textContent ) . toBe ( 'inserted' )
417
+ done ( )
418
+ } )
419
+ } )
420
+
400
421
} )
0 commit comments