@@ -271,18 +271,20 @@ describe('uiView', function () {
271271 } ) ;
272272
273273 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 ) {
275275 elem . append ( $compile ( '<div><ui-view></ui-view></div>' ) ( scope ) ) ;
276276 $state . transitionTo ( aState ) ;
277277 $q . flush ( ) ;
278- expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'ui-view' ) ) ;
278+ if ( $animate ) $animate . flush ( ) ;
279+ expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'span' ) . parent ( ) ) ;
279280 } ) ) ;
280281
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 ) {
282283 elem . append ( $compile ( '<div><ui-view autoscroll></ui-view></div>' ) ( scope ) ) ;
283284 $state . transitionTo ( aState ) ;
284285 $q . flush ( ) ;
285- expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'ui-view' ) ) ;
286+ if ( $animate ) $animate . flush ( ) ;
287+ expect ( $uiViewScroll ) . toHaveBeenCalledWith ( elem . find ( 'span' ) . parent ( ) ) ;
286288 } ) ) ;
287289
288290 it ( 'should autoscroll based on expression' , inject ( function ( $state , $q , $uiViewScroll , $animate ) {
@@ -298,7 +300,12 @@ describe('uiView', function () {
298300 $q . flush ( ) ;
299301 if ( $animate ) $animate . flush ( ) ;
300302
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 ) ;
302309 } ) ) ;
303310 } ) ;
304311
0 commit comments