@@ -17,7 +17,7 @@ describe('uiView', function () {
17
17
var log , scope , $compile , elem ;
18
18
19
19
beforeEach ( function ( ) {
20
- var depends = [ 'ui.router' , 'ui.router.state.events' ] ;
20
+ var depends = [ 'ui.router' ] ;
21
21
22
22
try {
23
23
angular . module ( 'ngAnimate' ) ;
@@ -31,8 +31,7 @@ describe('uiView', function () {
31
31
module ( 'ui.router.test' ) ;
32
32
} ) ;
33
33
34
- beforeEach ( module ( function ( $provide , $stateEventsProvider ) {
35
- $stateEventsProvider . enable ( ) ;
34
+ beforeEach ( module ( function ( $provide ) {
36
35
$provide . decorator ( '$uiViewScroll' , function ( ) {
37
36
return jasmine . createSpy ( '$uiViewScroll' ) ;
38
37
} ) ;
@@ -138,13 +137,17 @@ describe('uiView', function () {
138
137
. state ( 'm' , {
139
138
template : 'mState' ,
140
139
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
+ } ,
144
145
} )
145
146
. state ( 'n' , {
146
147
template : 'nState' ,
147
- controller : function ( $scope ) { log += 'ctrl(n);' ; }
148
+ controller : function ( $scope ) {
149
+ log += 'n;' ;
150
+ } ,
148
151
} )
149
152
. state ( 'o' , oState )
150
153
} ) ) ;
@@ -157,6 +160,23 @@ describe('uiView', function () {
157
160
158
161
describe ( 'linking ui-directive' , function ( ) {
159
162
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
+
160
180
it ( 'anonymous ui-view should be replaced with the template of the current $state' , inject ( function ( $state , $q ) {
161
181
elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
162
182
@@ -595,53 +615,6 @@ describe('uiView', function () {
595
615
// No more animations
596
616
expect ( $animate . queue . length ) . toBe ( 0 ) ;
597
617
} ) ) ;
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
- } ) ;
645
618
} ) ;
646
619
} ) ;
647
620
0 commit comments