@@ -991,6 +991,73 @@ if (!isIE9) {
991991 } ) . then ( done )
992992 } )
993993
994+ it ( 'transition in-out on async component' , done => {
995+ const vm = new Vue ( {
996+ template : `
997+ <div>
998+ <transition name="test-anim" mode="in-out">
999+ <component-a v-if="ok"></component-a>
1000+ <component-b v-else></component-b>
1001+ </transition>
1002+ </div>
1003+ ` ,
1004+ components : {
1005+ componentA : resolve => {
1006+ setTimeout ( ( ) => {
1007+ resolve ( { template : '<div><h1>component A</h1></div>' } )
1008+ next1 ( )
1009+ } , duration / 2 )
1010+ } ,
1011+ componentB : resolve => {
1012+ setTimeout ( ( ) => {
1013+ resolve ( { template : '<div><h1>component B</h1></div>' } )
1014+ next2 ( )
1015+ } , duration / 2 )
1016+ }
1017+ } ,
1018+ data : {
1019+ ok : true
1020+ }
1021+ } ) . $mount ( el )
1022+
1023+ expect ( vm . $el . innerHTML ) . toBe ( '<!---->' )
1024+
1025+ function next1 ( ) {
1026+ Vue . nextTick ( ( ) => {
1027+ expect ( vm . $el . children . length ) . toBe ( 1 )
1028+ expect ( vm . $el . textContent ) . toBe ( 'component A' )
1029+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test-anim-enter test-anim-enter-active' )
1030+ nextFrame ( ( ) => {
1031+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test-anim-enter-active test-anim-enter-to' )
1032+ setTimeout ( ( ) => {
1033+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( '' )
1034+ vm . ok = false
1035+ } , duration + buffer )
1036+ } )
1037+ } )
1038+ }
1039+
1040+ function next2 ( ) {
1041+ waitForUpdate ( ( ) => {
1042+ expect ( vm . $el . children . length ) . toBe ( 2 )
1043+ expect ( vm . $el . textContent ) . toBe ( 'component Acomponent B' )
1044+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( '' )
1045+ expect ( vm . $el . children [ 1 ] . className ) . toBe ( 'test-anim-enter test-anim-enter-active' )
1046+ } ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
1047+ expect ( vm . $el . children [ 1 ] . className ) . toBe ( 'test-anim-enter-active test-anim-enter-to' )
1048+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
1049+ expect ( vm . $el . children . length ) . toBe ( 2 )
1050+ expect ( vm . $el . textContent ) . toBe ( 'component Acomponent B' )
1051+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test-anim-leave-active test-anim-leave-to' )
1052+ expect ( vm . $el . children [ 1 ] . className ) . toBe ( '' )
1053+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
1054+ expect ( vm . $el . children . length ) . toBe ( 1 )
1055+ expect ( vm . $el . textContent ) . toBe ( 'component B' )
1056+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( '' )
1057+ } ) . then ( done )
1058+ }
1059+ } )
1060+
9941061 describe ( 'explicit durations -' , ( ) => {
9951062 it ( 'single value' , done => {
9961063 const vm = new Vue ( {
0 commit comments