@@ -900,7 +900,7 @@ describe('Ionic nav-view', function() {
900
900
expect ( afterLeave . stateName ) . toEqual ( 'page1' ) ;
901
901
expect ( leave . stateName ) . toEqual ( 'page1' ) ;
902
902
expect ( leave . transitionId ) . toEqual ( 2 ) ;
903
-
903
+
904
904
$state . go ( page1State ) ;
905
905
$q . flush ( ) ;
906
906
$timeout . flush ( ) ;
@@ -1009,6 +1009,59 @@ describe('Ionic nav-view', function() {
1009
1009
1010
1010
expect ( unloadedEvent . stateName ) . toEqual ( 'tabAbstract.tab3page1' ) ;
1011
1011
} ) ) ;
1012
+
1013
+ it ( 'should emit $ionicView events in correct order' , inject ( function ( $state , $q , $timeout , $compile , $ionicConfig ) {
1014
+ $ionicConfig . views . maxCache ( 0 ) ;
1015
+
1016
+ var order = [ ] ;
1017
+ scope . $on ( '$ionicView.loaded' , function ( ev , d ) {
1018
+ order . push ( '$ionicView.loaded' ) ;
1019
+ } ) ;
1020
+ scope . $on ( '$ionicView.beforeEnter' , function ( ev , d ) {
1021
+ order . push ( '$ionicView.beforeEnter' ) ;
1022
+ } ) ;
1023
+ scope . $on ( '$ionicView.enter' , function ( ev , d ) {
1024
+ order . push ( '$ionicView.enter' ) ;
1025
+ } ) ;
1026
+ scope . $on ( '$ionicView.afterEnter' , function ( ev , d ) {
1027
+ order . push ( '$ionicView.afterEnter' ) ;
1028
+ } ) ;
1029
+ scope . $on ( '$ionicView.beforeLeave' , function ( ev , d ) {
1030
+ order . push ( '$ionicView.beforeLeave' ) ;
1031
+ } ) ;
1032
+ scope . $on ( '$ionicView.leave' , function ( ev , d ) {
1033
+ order . push ( '$ionicView.leave' ) ;
1034
+ } ) ;
1035
+ scope . $on ( '$ionicView.afterLeave' , function ( ev , d ) {
1036
+ order . push ( '$ionicView.afterLeave' ) ;
1037
+ } ) ;
1038
+ scope . $on ( '$ionicView.unloaded' , function ( ev , d ) {
1039
+ order . push ( '$ionicView.unloaded' ) ;
1040
+ } ) ;
1041
+
1042
+ elem . append ( $compile ( '<div><ion-nav-view></ion-nav-view></div>' ) ( scope ) ) ;
1043
+
1044
+ $state . go ( page1State ) ;
1045
+ $q . flush ( ) ;
1046
+ $timeout . flush ( ) ;
1047
+
1048
+ $state . go ( page2State ) ;
1049
+ $q . flush ( ) ;
1050
+ $timeout . flush ( ) ;
1051
+
1052
+ expect ( order [ 0 ] ) . toEqual ( '$ionicView.loaded' ) ;
1053
+ expect ( order [ 1 ] ) . toEqual ( '$ionicView.beforeEnter' ) ;
1054
+ expect ( order [ 2 ] ) . toEqual ( '$ionicView.enter' ) ;
1055
+ expect ( order [ 3 ] ) . toEqual ( '$ionicView.afterEnter' ) ;
1056
+ expect ( order [ 4 ] ) . toEqual ( '$ionicView.loaded' ) ;
1057
+ expect ( order [ 5 ] ) . toEqual ( '$ionicView.beforeEnter' ) ;
1058
+ expect ( order [ 6 ] ) . toEqual ( '$ionicView.beforeLeave' ) ;
1059
+ expect ( order [ 7 ] ) . toEqual ( '$ionicView.enter' ) ;
1060
+ expect ( order [ 8 ] ) . toEqual ( '$ionicView.leave' ) ;
1061
+ expect ( order [ 9 ] ) . toEqual ( '$ionicView.afterEnter' ) ;
1062
+ expect ( order [ 10 ] ) . toEqual ( '$ionicView.afterLeave' ) ;
1063
+ expect ( order [ 11 ] ) . toEqual ( '$ionicView.unloaded' ) ;
1064
+ } ) ) ;
1012
1065
1013
1066
it ( 'should clear ion-nav-view cache' , inject ( function ( $state , $q , $timeout , $compile , $ionicHistory ) {
1014
1067
elem . append ( $compile ( '<div><ion-nav-view></ion-nav-view></div>' ) ( scope ) ) ;
0 commit comments