@@ -17,7 +17,7 @@ describe('uiView', function () {
1717 var log , scope , $compile , elem ;
1818
1919 beforeEach ( function ( ) {
20- var depends = [ 'ui.router' , 'ui.router.state.events' ] ;
20+ var depends = [ 'ui.router' ] ;
2121
2222 try {
2323 angular . module ( 'ngAnimate' ) ;
@@ -31,8 +31,7 @@ describe('uiView', function () {
3131 module ( 'ui.router.test' ) ;
3232 } ) ;
3333
34- beforeEach ( module ( function ( $provide , $stateEventsProvider ) {
35- $stateEventsProvider . enable ( ) ;
34+ beforeEach ( module ( function ( $provide ) {
3635 $provide . decorator ( '$uiViewScroll' , function ( ) {
3736 return jasmine . createSpy ( '$uiViewScroll' ) ;
3837 } ) ;
@@ -138,13 +137,17 @@ describe('uiView', function () {
138137 . state ( 'm' , {
139138 template : 'mState' ,
140139 controller : function ( $scope ) {
141- log += 'ctrl(m);' ;
142- $scope . $on ( '$destroy' , function ( ) { log += '$destroy(m);' ; } ) ;
143- }
140+ log += 'm;' ;
141+ $scope . $on ( '$destroy' , function ( ) {
142+ log += '$destroy(m);' ;
143+ } ) ;
144+ } ,
144145 } )
145146 . state ( 'n' , {
146147 template : 'nState' ,
147- controller : function ( $scope ) { log += 'ctrl(n);' ; }
148+ controller : function ( $scope ) {
149+ log += 'n;' ;
150+ } ,
148151 } )
149152 . state ( 'o' , oState )
150153 } ) ) ;
@@ -157,6 +160,23 @@ describe('uiView', function () {
157160
158161 describe ( 'linking ui-directive' , function ( ) {
159162
163+ it ( '$destroy event is triggered after animation ends' , inject ( function ( $state , $q , $animate ) {
164+ elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
165+
166+ $state . transitionTo ( 'm' ) ;
167+ $q . flush ( ) ;
168+ expect ( log ) . toBe ( 'm;' ) ;
169+ $state . transitionTo ( 'n' ) ;
170+ $q . flush ( ) ;
171+ if ( $animate ) {
172+ expect ( log ) . toBe ( 'm;n;' ) ;
173+ animateFlush ( $animate ) ;
174+ expect ( log ) . toBe ( 'm;n;$destroy(m);' ) ;
175+ } else {
176+ expect ( log ) . toBe ( 'm;$destroy(m);n;' ) ;
177+ }
178+ } ) ) ;
179+
160180 it ( 'anonymous ui-view should be replaced with the template of the current $state' , inject ( function ( $state , $q ) {
161181 elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
162182
@@ -595,53 +615,6 @@ describe('uiView', function () {
595615 // No more animations
596616 expect ( $animate . queue . length ) . toBe ( 0 ) ;
597617 } ) ) ;
598-
599- it ( 'should disable animations if noanimation="true" is present' , inject ( function ( $state , $q , $compile , $animate ) {
600- var content = 'Initial Content' , animation ;
601- elem . append ( $compile ( '<div><ui-view noanimation="true">' + content + '</ui-view></div>' ) ( scope ) ) ;
602-
603- animation = $animate . queue . shift ( ) ;
604- expect ( animation ) . toBeUndefined ( ) ;
605-
606- $state . transitionTo ( aState ) ;
607- $q . flush ( ) ;
608- animation = $animate . queue . shift ( ) ;
609- expect ( animation ) . toBeUndefined ( ) ;
610- expect ( elem . text ( ) ) . toBe ( aState . template ) ;
611-
612- $state . transitionTo ( bState ) ;
613- $q . flush ( ) ;
614- animation = $animate . queue . shift ( ) ;
615- expect ( animation ) . toBeUndefined ( ) ;
616- expect ( elem . text ( ) ) . toBe ( bState . template ) ;
617- } ) ) ;
618-
619- describe ( '$destroy event' , function ( ) {
620- it ( 'is triggered after animation ends' , inject ( function ( $state , $q , $animate , $rootScope ) {
621- elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
622-
623- $state . transitionTo ( 'm' ) ;
624- $q . flush ( ) ;
625- expect ( log ) . toBe ( 'ctrl(m);' ) ;
626- $state . transitionTo ( 'n' ) ;
627- $q . flush ( ) ;
628-
629- expect ( log ) . toBe ( 'ctrl(m);ctrl(n);' ) ;
630- animateFlush ( $animate ) ;
631- expect ( log ) . toBe ( 'ctrl(m);ctrl(n);$destroy(m);' ) ;
632- } ) ) ;
633-
634- it ( 'is triggered before $stateChangeSuccess if noanimation is present' , inject ( function ( $state , $q , $animate , $rootScope ) {
635- elem . append ( $compile ( '<div><ui-view noanimation="true"></ui-view></div>' ) ( scope ) ) ;
636-
637- $state . transitionTo ( 'm' ) ;
638- $q . flush ( ) ;
639- expect ( log ) . toBe ( 'ctrl(m);' ) ;
640- $state . transitionTo ( 'n' ) ;
641- $q . flush ( ) ;
642- expect ( log ) . toBe ( 'ctrl(m);$destroy(m);ctrl(n);' ) ;
643- } ) ) ;
644- } ) ;
645618 } ) ;
646619} ) ;
647620
0 commit comments