Skip to content

Commit fb5e88c

Browse files
committed
test(infiniteScroll): fix inconsistent failing unit test
1 parent 580a955 commit fb5e88c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/unit/angular/directive/infiniteScroll.unit.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,13 @@ describe('ionicInfiniteScroll directive', function() {
159159
});
160160

161161
setupNative('', {}, opts);
162+
var tmp = window.getComputedStyle;
163+
window.getComputedStyle = function() {return {};};
162164
expect(ctrl.getNativeMaxScroll()).toEqual({
163165
left: opts.scrollingX ? scrollLeftMaxValue * 0.975 : -1,
164166
top: opts.scrollingY ? scrollTopMaxValue * 0.975 : -1
165167
});
168+
window.getComputedStyle = tmp;
166169
});
167170

168171
it('should use attr.distance as number', function() {
@@ -173,10 +176,14 @@ describe('ionicInfiniteScroll directive', function() {
173176
});
174177

175178
setupNative('distance=3', {}, opts);
179+
180+
var tmp = window.getComputedStyle;
181+
window.getComputedStyle = function() {return {};};
176182
expect(ctrl.getNativeMaxScroll()).toEqual({
177183
left: opts.scrollingX ? scrollLeftMaxValue - 3 : -1,
178184
top: opts.scrollingY ? scrollTopMaxValue - 3 : -1
179185
});
186+
window.getComputedStyle = tmp;
180187
});
181188

182189
it('should use attr.distance as percent', function() {
@@ -187,10 +194,14 @@ describe('ionicInfiniteScroll directive', function() {
187194
});
188195

189196
setupNative('distance=5%', {}, opts);
197+
198+
var tmp = window.getComputedStyle;
199+
window.getComputedStyle = function() {return {};};
190200
expect(ctrl.getNativeMaxScroll()).toEqual({
191201
left: opts.scrollingX ? scrollLeftMaxValue * 0.95 : -1,
192202
top: opts.scrollingY ? scrollTopMaxValue * 0.95 : -1
193203
});
204+
window.getComputedStyle = tmp;
194205
});
195206
});
196207

@@ -232,7 +243,11 @@ describe('ionicInfiniteScroll directive', function() {
232243
scrollTopValue = scrollTopMaxValue;
233244
var el = setupNative('on-infinite="foo=1"', {}, { scrollingX: true, scrollingY: true });
234245
ionic.requestAnimationFrame = function(cb) { cb(); };
246+
247+
var tmp = window.getComputedStyle;
248+
window.getComputedStyle = function() {return {};};
235249
ctrl.checkBounds();
250+
window.getComputedStyle = tmp;
236251
expect(el.hasClass('active')).toBe(true);
237252
ionic.requestAnimationFrame = function() {};
238253
expect(ctrl.isLoading).toBe(true);
@@ -252,7 +267,11 @@ describe('ionicInfiniteScroll directive', function() {
252267
scrollLeftValue = scrollLeftMaxValue;
253268
var el = setupNative('on-infinite="foo=1"', {}, { scrollingX: true, scrollingY: true });
254269
ionic.requestAnimationFrame = function(cb) { cb(); };
270+
271+
var tmp = window.getComputedStyle;
272+
window.getComputedStyle = function() {return {};};
255273
ctrl.checkBounds();
274+
window.getComputedStyle = tmp;
256275

257276
expect(el.hasClass('active')).toBe(true);
258277
ionic.requestAnimationFrame = function() {};

0 commit comments

Comments
 (0)