@@ -123,16 +123,12 @@ describe('uiView', function () {
123123 . state ( 'l' , lState )
124124 . state ( 'm' , {
125125 controller : function ( $scope ) {
126- log += 'm;' ;
127- $scope . $on ( '$destroy' , function ( ) {
128- log += '$destroy(m);' ;
129- } ) ;
130- } ,
126+ log += 'ctrl(m);' ;
127+ $scope . $on ( '$destroy' , function ( ) { log += '$destroy(m);' ; } ) ;
128+ }
131129 } )
132130 . state ( 'n' , {
133- controller : function ( $scope ) {
134- log += 'n;' ;
135- } ,
131+ controller : function ( $scope ) { log += 'ctrl(n);' ; }
136132 } ) ;
137133 } ) ) ;
138134
@@ -144,23 +140,6 @@ describe('uiView', function () {
144140
145141 describe ( 'linking ui-directive' , function ( ) {
146142
147- it ( '$destroy event is triggered after animation ends' , inject ( function ( $state , $q , $animate ) {
148- elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
149-
150- $state . transitionTo ( 'm' ) ;
151- $q . flush ( ) ;
152- expect ( log ) . toBe ( 'm;' ) ;
153- $state . transitionTo ( 'n' ) ;
154- $q . flush ( ) ;
155- if ( $animate ) {
156- expect ( log ) . toBe ( 'm;n;' ) ;
157- animateFlush ( $animate ) ;
158- expect ( log ) . toBe ( 'm;n;$destroy(m);' ) ;
159- } else {
160- expect ( log ) . toBe ( 'm;$destroy(m);n;' ) ;
161- }
162- } ) ) ;
163-
164143 it ( 'anonymous ui-view should be replaced with the template of the current $state' , inject ( function ( $state , $q ) {
165144 elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
166145
@@ -594,5 +573,56 @@ describe('uiView', function () {
594573 // No more animations
595574 expect ( $animate . queue . length ) . toBe ( 0 ) ;
596575 } ) ) ;
576+
577+ it ( 'should disable animations if noanimation="true" is present' , inject ( function ( $state , $q , $compile , $animate ) {
578+ var content = 'Initial Content' , animation ;
579+ elem . append ( $compile ( '<div><ui-view noanimation="true">' + content + '</ui-view></div>' ) ( scope ) ) ;
580+
581+ animation = $animate . queue . shift ( ) ;
582+ expect ( animation ) . toBeUndefined ( ) ;
583+
584+ $state . transitionTo ( aState ) ;
585+ $q . flush ( ) ;
586+ animation = $animate . queue . shift ( ) ;
587+ expect ( animation ) . toBeUndefined ( ) ;
588+ expect ( elem . text ( ) ) . toBe ( aState . template ) ;
589+
590+ $state . transitionTo ( bState ) ;
591+ $q . flush ( ) ;
592+ animation = $animate . queue . shift ( ) ;
593+ expect ( animation ) . toBeUndefined ( ) ;
594+ expect ( elem . text ( ) ) . toBe ( bState . template ) ;
595+ } ) ) ;
596+
597+ it ( '$destroy event is triggered after animation ends' , inject ( function ( $state , $q , $animate , $rootScope ) {
598+ elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
599+ $rootScope . $on ( '$stateChangeSuccess' , function ( evt , toState ) { log += 'success(' + toState . name + ');' ; } ) ;
600+
601+ $state . transitionTo ( 'm' ) ;
602+ $q . flush ( ) ;
603+ expect ( log ) . toBe ( 'success(m);ctrl(m);' ) ;
604+ $state . transitionTo ( 'n' ) ;
605+ $q . flush ( ) ;
606+ if ( $animate ) {
607+ expect ( log ) . toBe ( 'success(m);ctrl(m);success(n);ctrl(n);' ) ;
608+ animateFlush ( $animate ) ;
609+ expect ( log ) . toBe ( 'success(m);ctrl(m);success(n);ctrl(n);$destroy(m);' ) ;
610+ } else {
611+ expect ( log ) . toBe ( 'success(m);ctrl(m);$destroy(m);success(n);ctrl(n);' ) ;
612+ }
613+ } ) ) ;
614+
615+ it ( '$destroy event is triggered before $stateChangeSuccess if noanimation is present' , inject ( function ( $state , $q , $animate , $rootScope ) {
616+ elem . append ( $compile ( '<div><ui-view noanimation="true"></ui-view></div>' ) ( scope ) ) ;
617+ $rootScope . $on ( '$stateChangeSuccess' , function ( evt , toState ) { log += 'success(' + toState . name + ');' ; } ) ;
618+
619+ $state . transitionTo ( 'm' ) ;
620+ $q . flush ( ) ;
621+ expect ( log ) . toBe ( 'success(m);ctrl(m);' ) ;
622+ $state . transitionTo ( 'n' ) ;
623+ $q . flush ( ) ;
624+ expect ( log ) . toBe ( 'success(m);ctrl(m);success(n);$destroy(m);ctrl(n);' ) ;
625+ } ) ) ;
626+
597627 } ) ;
598628} ) ;
0 commit comments