@@ -342,6 +342,50 @@ if (_.inBrowser && !_.isIE9) {
342342 }
343343 } )
344344
345+ it ( 'css + js hook with callback before transitionend' , function ( done ) {
346+ document . body . removeChild ( el )
347+ el . classList . add ( 'test' )
348+
349+ // enter hook that expects a second argument
350+ // indicates the user wants to control when the
351+ // transition ends.
352+ var enterCalled = false
353+ hooks . enter = function ( el , enterDone ) {
354+ enterCalled = true
355+ setTimeout ( function ( ) {
356+ enterDone ( )
357+ testDone ( )
358+ } , 20 )
359+ }
360+
361+ el . __v_trans = new Transition ( el , 'test' , hooks , vm )
362+ transition . apply ( el , 1 , function ( ) {
363+ document . body . appendChild ( el )
364+ op ( )
365+ } , vm , cb )
366+ expect ( hooks . beforeEnter ) . toHaveBeenCalled ( )
367+ expect ( op ) . toHaveBeenCalled ( )
368+ expect ( cb ) . not . toHaveBeenCalled ( )
369+ expect ( enterCalled ) . toBe ( true )
370+ _ . nextTick ( function ( ) {
371+ expect ( el . classList . contains ( 'test-enter' ) ) . toBe ( false )
372+ expect ( hooks . afterEnter ) . not . toHaveBeenCalled ( )
373+ _ . on ( el , _ . transitionEndEvent , function ( ) {
374+ // callback should have been called, but only once, by the js callback
375+ expect ( cb ) . toHaveBeenCalled ( )
376+ expect ( cb . calls . count ( ) ) . toBe ( 1 )
377+ expect ( hooks . afterEnter ) . toHaveBeenCalled ( )
378+ done ( )
379+ } )
380+ } )
381+
382+ // this is called by the enter hook
383+ function testDone ( ) {
384+ expect ( cb ) . toHaveBeenCalled ( )
385+ expect ( hooks . afterEnter ) . toHaveBeenCalled ( )
386+ }
387+ } )
388+
345389 it ( 'clean up unfinished css callback' , function ( done ) {
346390 el . __v_trans = new Transition ( el , 'test' , null , vm )
347391 el . classList . add ( 'test' )
0 commit comments