@@ -271,18 +271,20 @@ describe('uiView', function () {
271
271
} ) ;
272
272
273
273
describe ( 'autoscroll attribute' , function ( ) {
274
- it ( 'should autoscroll when unspecified' , inject ( function ( $state , $q , $uiViewScroll ) {
274
+ it ( 'should autoscroll when unspecified' , inject ( function ( $state , $q , $uiViewScroll , $animate ) {
275
275
elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
276
276
$state . transitionTo ( aState ) ;
277
277
$q . flush ( ) ;
278
- expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'ui-view' ) ) ;
278
+ if ( $animate ) $animate . flush ( ) ;
279
+ expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'span' ) . parent ( ) ) ;
279
280
} ) ) ;
280
281
281
- it ( 'should autoscroll when expression is missing' , inject ( function ( $state , $q , $uiViewScroll ) {
282
+ it ( 'should autoscroll when expression is missing' , inject ( function ( $state , $q , $uiViewScroll , $animate ) {
282
283
elem . append ( $compile ( '<div><ui-view autoscroll></ui-view></div>' ) ( scope ) ) ;
283
284
$state . transitionTo ( aState ) ;
284
285
$q . flush ( ) ;
285
- expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'ui-view' ) ) ;
286
+ if ( $animate ) $animate . flush ( ) ;
287
+ expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'span' ) . parent ( ) ) ;
286
288
} ) ) ;
287
289
288
290
it ( 'should autoscroll based on expression' , inject ( function ( $state , $q , $uiViewScroll , $animate ) {
@@ -298,7 +300,12 @@ describe('uiView', function () {
298
300
$q . flush ( ) ;
299
301
if ( $animate ) $animate . flush ( ) ;
300
302
301
- expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'ui-view' ) ) ;
303
+ var target ;
304
+ angular . forEach ( elem . find ( 'ui-view' ) , function ( view ) {
305
+ if ( angular . element ( view ) . text ( ) === bState . template ) target = angular . element ( view ) ;
306
+ } ) ;
307
+
308
+ expect ( $uiViewScroll ) . toHaveBeenCalledWith ( target ) ;
302
309
} ) ) ;
303
310
} ) ;
304
311
0 commit comments