@@ -97,13 +97,14 @@ describe('anchorScroll', function() {
97
97
98
98
function testWithAnimate ( animate ) {
99
99
describe ( 'with animate=' + animate , function ( ) {
100
- var contentEl , scope , del ;
100
+ var contentEl , scope , del , timeout ;
101
101
beforeEach ( inject ( function ( $rootScope , $compile , $timeout , $document , $ionicScrollDelegate ) {
102
102
scope = $rootScope . $new ( ) ;
103
103
contentEl = $compile ( '<content></content>' ) ( scope ) ;
104
104
105
105
document . body . appendChild ( contentEl [ 0 ] ) ;
106
106
del = $ionicScrollDelegate ;
107
+ timeout = $timeout ;
107
108
} ) ) ;
108
109
109
110
it ( 'should anchorScroll to an element with id' , function ( ) {
@@ -118,6 +119,7 @@ describe('anchorScroll', function() {
118
119
contentEl . append ( anchorMe ) ;
119
120
120
121
del . anchorScroll ( animate ) ;
122
+ timeout . flush ( ) ;
121
123
expect ( sv . scrollTo ) . toHaveBeenCalledWith ( 2 , 1 , animate ) ;
122
124
} ) ;
123
125
@@ -126,6 +128,8 @@ describe('anchorScroll', function() {
126
128
spyOn ( sv , 'scrollTo' ) ;
127
129
spyOn ( ionic . DomUtil , 'getPositionInParent' ) ;
128
130
del . anchorScroll ( animate ) ;
131
+ timeout . flush ( ) ;
132
+
129
133
expect ( sv . scrollTo ) . toHaveBeenCalledWith ( 0 , 0 , animate ) ;
130
134
expect ( ionic . DomUtil . getPositionInParent ) . not . toHaveBeenCalled ( ) ;
131
135
} ) ;
@@ -137,6 +141,7 @@ describe('anchorScroll', function() {
137
141
138
142
setLocationHash ( 'doesnotexist' ) ;
139
143
del . anchorScroll ( animate ) ;
144
+ timeout . flush ( ) ;
140
145
141
146
expect ( sv . scrollTo ) . toHaveBeenCalledWith ( 0 , 0 , animate ) ;
142
147
expect ( ionic . DomUtil . getPositionInParent ) . not . toHaveBeenCalled ( ) ;
0 commit comments