@@ -842,7 +842,7 @@ if (!isIE9) {
842
842
} ) . then ( done )
843
843
} )
844
844
845
- it ( 'transition inside child component' , done => {
845
+ it ( 'transition inside child component with v-if ' , done => {
846
846
const vm = new Vue ( {
847
847
template : `
848
848
<div>
@@ -872,14 +872,126 @@ if (!isIE9) {
872
872
expect ( vm . $el . children . length ) . toBe ( 0 )
873
873
vm . ok = true
874
874
} ) . then ( ( ) => {
875
- expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-enter v-enter-active' )
875
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test' )
876
+ } ) . then ( done )
877
+ } )
878
+
879
+ it ( 'transition with appear inside child component with v-if' , done => {
880
+ const vm = new Vue ( {
881
+ template : `
882
+ <div>
883
+ <test v-if="ok" class="test"></test>
884
+ </div>
885
+ ` ,
886
+ data : { ok : true } ,
887
+ components : {
888
+ test : {
889
+ template : `
890
+ <transition appear
891
+ appear-class="test-appear"
892
+ appear-to-class="test-appear-to"
893
+ appear-active-class="test-appear-active">
894
+ <div>foo</div>
895
+ </transition>
896
+ `
897
+ }
898
+ }
899
+ } ) . $mount ( el )
900
+
901
+ waitForUpdate ( ( ) => {
902
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test test-appear test-appear-active' )
876
903
} ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
877
- expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-enter-active v-enter-to' )
904
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test test-appear-active test-appear-to' )
905
+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
906
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test' )
907
+ vm . ok = false
908
+ } ) . then ( ( ) => {
909
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-leave v-leave-active' )
910
+ } ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
911
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-leave-active v-leave-to' )
912
+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
913
+ expect ( vm . $el . children . length ) . toBe ( 0 )
914
+ } ) . then ( done )
915
+ } )
916
+
917
+ it ( 'transition inside nested child component with v-if' , done => {
918
+ const vm = new Vue ( {
919
+ template : `
920
+ <div>
921
+ <foo v-if="ok" class="test"></foo>
922
+ </div>
923
+ ` ,
924
+ data : { ok : true } ,
925
+ components : {
926
+ foo : {
927
+ template : '<bar></bar>' ,
928
+ components : {
929
+ bar : {
930
+ template : '<transition><div>foo</div></transition>'
931
+ }
932
+ }
933
+ }
934
+ }
935
+ } ) . $mount ( el )
936
+
937
+ // should not apply transition on initial render by default
938
+ expect ( vm . $el . innerHTML ) . toBe ( '<div class="test">foo</div>' )
939
+ vm . ok = false
940
+ waitForUpdate ( ( ) => {
941
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-leave v-leave-active' )
942
+ } ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
943
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-leave-active v-leave-to' )
878
944
} ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
945
+ expect ( vm . $el . children . length ) . toBe ( 0 )
946
+ vm . ok = true
947
+ } ) . then ( ( ) => {
879
948
expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test' )
880
949
} ) . then ( done )
881
950
} )
882
951
952
+ it ( 'transition with appear inside nested child component with v-if' , done => {
953
+ const vm = new Vue ( {
954
+ template : `
955
+ <div>
956
+ <foo v-if="ok" class="test"></foo>
957
+ </div>
958
+ ` ,
959
+ data : { ok : true } ,
960
+ components : {
961
+ foo : {
962
+ template : '<bar></bar>' ,
963
+ components : {
964
+ bar : {
965
+ template : `
966
+ <transition appear
967
+ appear-class="test-appear"
968
+ appear-to-class="test-appear-to"
969
+ appear-active-class="test-appear-active">
970
+ <div>foo</div>
971
+ </transition>
972
+ `
973
+ }
974
+ }
975
+ }
976
+ }
977
+ } ) . $mount ( el )
978
+
979
+ waitForUpdate ( ( ) => {
980
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test test-appear test-appear-active' )
981
+ } ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
982
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test test-appear-active test-appear-to' )
983
+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
984
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test' )
985
+ vm . ok = false
986
+ } ) . then ( ( ) => {
987
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-leave v-leave-active' )
988
+ } ) . thenWaitFor ( nextFrame ) . then ( ( ) => {
989
+ expect ( vm . $el . children [ 0 ] . className ) . toBe ( 'test v-leave-active v-leave-to' )
990
+ } ) . thenWaitFor ( duration + buffer ) . then ( ( ) => {
991
+ expect ( vm . $el . children . length ) . toBe ( 0 )
992
+ } ) . then ( done )
993
+ } )
994
+
883
995
it ( 'custom transition higher-order component' , done => {
884
996
const vm = new Vue ( {
885
997
template : '<div><my-transition><div v-if="ok" class="test">foo</div></my-transition></div>' ,
0 commit comments