From d39f21f410a69b9ee66e7fb2e5288215c93a2e9a Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 29 Feb 2016 13:27:44 -0600 Subject: [PATCH] test(refresher): fix refresher unit tests --- ionic/components/refresher/refresher.ts | 3 ++- ionic/components/refresher/test/refresher.spec.ts | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ionic/components/refresher/refresher.ts b/ionic/components/refresher/refresher.ts index 2ffc4a2307..e0db9ff487 100644 --- a/ionic/components/refresher/refresher.ts +++ b/ionic/components/refresher/refresher.ts @@ -302,12 +302,13 @@ export class Refresher { // this refresh is not already actively pulling down // get the content's scrollTop - let scrollHostScrollTop = this._content.scrollElement.scrollTop; + let scrollHostScrollTop = this._content.getContentDimensions().scrollTop; // if the scrollTop is greater than zero then it's // not possible to pull the content down yet if (scrollHostScrollTop > 0) { this.progress = 0; + this.startY = null; return 7; } diff --git a/ionic/components/refresher/test/refresher.spec.ts b/ionic/components/refresher/test/refresher.spec.ts index 70ff1c3835..10f7d13f28 100644 --- a/ionic/components/refresher/test/refresher.spec.ts +++ b/ionic/components/refresher/test/refresher.spec.ts @@ -119,6 +119,8 @@ describe('Refresher', () => { let result = refresher._onMove( touchEv(125) ); expect(refresher.state).toEqual('inactive'); + expect(refresher.progress).toEqual(0); + expect(refresher.startY).toEqual(null); expect(result).toEqual(7); }); @@ -153,13 +155,16 @@ describe('Refresher', () => { }); it('should set the deltaY', () => { + setContentScrollTop(1); refresher.startY = 100; refresher._onMove( touchEv(133) ); expect(refresher.deltaY).toEqual(33); refresher._lastCheck = 0; // force allow next check + refresher.startY = 100; - refresher._onMove( touchEv(50) ); + var results = refresher._onMove( touchEv(50) ); + expect(results).toEqual(6); expect(refresher.deltaY).toEqual(-50); }); @@ -245,7 +250,11 @@ describe('Refresher', () => { } function setContentScrollTop(scrollTop) { - contentElementRef.nativeElement.scrollTop = scrollTop; + content.getContentDimensions = function() { + return { + scrollTop: scrollTop + }; + }; } function getScrollElementStyles() {