11var Vue = require ( 'src' )
2- var _ = require ( 'src/util' )
2+ var nextTick = Vue . nextTick
33
44describe ( 'Slot Distribution' , function ( ) {
55
@@ -158,7 +158,7 @@ describe('Slot Distribution', function () {
158158 } )
159159 expect ( el . innerHTML ) . toBe ( '<test>hello</test>' )
160160 vm . msg = 'what'
161- _ . nextTick ( function ( ) {
161+ nextTick ( function ( ) {
162162 expect ( el . innerHTML ) . toBe ( '<test>what</test>' )
163163 done ( )
164164 } )
@@ -182,14 +182,14 @@ describe('Slot Distribution', function () {
182182 } )
183183 expect ( el . textContent ) . toBe ( '12' )
184184 vm . a = 2
185- _ . nextTick ( function ( ) {
185+ nextTick ( function ( ) {
186186 expect ( el . textContent ) . toBe ( '22' )
187187 vm . show = false
188- _ . nextTick ( function ( ) {
188+ nextTick ( function ( ) {
189189 expect ( el . textContent ) . toBe ( '' )
190190 vm . show = true
191191 vm . a = 3
192- _ . nextTick ( function ( ) {
192+ nextTick ( function ( ) {
193193 expect ( el . textContent ) . toBe ( '32' )
194194 done ( )
195195 } )
@@ -237,7 +237,7 @@ describe('Slot Distribution', function () {
237237 markup = vm . list . map ( function ( item ) {
238238 return '<div class="child parent">' + item . a + ' ho</div>'
239239 } ) . join ( '' )
240- _ . nextTick ( function ( ) {
240+ nextTick ( function ( ) {
241241 expect ( el . innerHTML ) . toBe ( markup )
242242 done ( )
243243 } )
@@ -266,7 +266,7 @@ describe('Slot Distribution', function () {
266266 '</testb></testa>'
267267 )
268268 vm . list . push ( 3 )
269- _ . nextTick ( function ( ) {
269+ nextTick ( function ( ) {
270270 expect ( el . innerHTML ) . toBe (
271271 '<testa><testb>' +
272272 '<div>1</div><div>2</div><div>3</div>' +
@@ -297,7 +297,7 @@ describe('Slot Distribution', function () {
297297 } )
298298 expect ( el . innerHTML ) . toBe ( '<testa></testa>' )
299299 vm . ok = true
300- _ . nextTick ( function ( ) {
300+ nextTick ( function ( ) {
301301 expect ( el . innerHTML ) . toBe ( '<testa><testb>hello</testb></testa>' )
302302 done ( )
303303 } )
@@ -397,4 +397,25 @@ describe('Slot Distribution', function () {
397397 expect ( el . textContent ) . toBe ( 'hihihi' )
398398 } )
399399
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+
400421} )
0 commit comments