From 050b600940bb1510f98482d91cf9bebcd80b88d8 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Fri, 13 Nov 2015 17:12:15 -0600 Subject: [PATCH] fix(popTo): fix reference and tests Closes #511 --- ionic/components/content/content.ts | 12 ++++++ ionic/components/nav/nav-controller.ts | 2 +- .../nav/test/nav-controller.spec.ts | 39 ++++++++++++++++++- .../tap-click/test/tapClick.spec.ts | 2 +- ionic/config/bootstrap.ts | 2 +- ionic/config/test/config.spec.ts | 6 +-- 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/ionic/components/content/content.ts b/ionic/components/content/content.ts index c4bb2649b0..20e36ddb5b 100644 --- a/ionic/components/content/content.ts +++ b/ionic/components/content/content.ts @@ -73,6 +73,18 @@ export class Content extends Ion { } } + onScrollEnd(callback) { + let timerId; + + function debounce() { + timerId = setTimeout(() => { + + }, 250); + } + + this.addScrollEventListener(debounce); + } + /** * Adds the specified touchmove handler to the content's scroll element. * @param {Function} handler The touchmove handler. diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 6bfe247320..c1fc8f77de 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -293,7 +293,7 @@ export class NavController extends Ion { * @param opts extra animation options */ popToRoot(opts = {}) { - return this._popTo(this.first(), opts); + return this.popTo(this.first(), opts); } /** diff --git a/ionic/components/nav/test/nav-controller.spec.ts b/ionic/components/nav/test/nav-controller.spec.ts index 801fd1809d..9e69fad948 100644 --- a/ionic/components/nav/test/nav-controller.spec.ts +++ b/ionic/components/nav/test/nav-controller.spec.ts @@ -199,6 +199,41 @@ export function run() { }); }); + describe("first", () => { + it('should get the first item', () => { + let vc1 = new ViewController(), + vc2 = new ViewController(null, FirstPage), + vc3 = new ViewController(null, SecondPage); + nav._views = [vc1, vc2, vc3]; + + expect(nav.first()).toBe(vc1); + }); + it('should get the first item that isnt being destroyed', () => { + let vc1 = new ViewController(), + vc2 = new ViewController(), + vc3 = new ViewController(); + vc1.shouldDestroy = true; + nav._views = [vc1, vc2, vc3]; + + expect(nav.first()).toBe(vc2); + }); + }); + + describe("popTo", () => { + it('should popTo 1st view', () => { + let vc1 = new ViewController(null, FirstPage), + vc2 = new ViewController(null, SecondPage), + vc3 = new ViewController(null, ThirdPage); + nav._views = [vc1, vc2, vc3]; + + nav._transition = mockTransitionFn; + nav.popTo(vc1); + + expect(nav._views.length).toBe(1); + expect(nav._views[0].componentType).toBe(FirstPage); + }); + }); + describe("remove", () => { it('should remove the view at the specified index', () => { let vc1 = new ViewController(), @@ -234,10 +269,10 @@ export function run() { }); describe("_setZIndex", () => { - it('should set zIndex 0 on first entering view', () => { + it('should set zIndex 10 on first entering view', () => { let enteringInstance = {}; nav._setZIndex(enteringInstance, null, 'forward'); - expect(enteringInstance._zIndex).toEqual(0); + expect(enteringInstance._zIndex).toEqual(10); }); it('should set zIndex 1 on second entering view', () => { diff --git a/ionic/components/tap-click/test/tapClick.spec.ts b/ionic/components/tap-click/test/tapClick.spec.ts index ba51b24fde..b275d3d6d6 100644 --- a/ionic/components/tap-click/test/tapClick.spec.ts +++ b/ionic/components/tap-click/test/tapClick.spec.ts @@ -18,7 +18,7 @@ export function run() { it('should be activatable on element', () => { let ele = document.createElement('ion-item-sliding'); - expect( tapClick.isActivatable(ele) ).toBe(true); + expect( tapClick.isActivatable(ele) ).toBe(false); }); it('should be not activatable on element', () => { diff --git a/ionic/config/bootstrap.ts b/ionic/config/bootstrap.ts index ed3ee24618..5f3e8a522f 100644 --- a/ionic/config/bootstrap.ts +++ b/ionic/config/bootstrap.ts @@ -21,7 +21,7 @@ import {initTapClick} from '../components/tap-click/tap-click'; import * as dom from '../util/dom'; -export function ionicProviders(args) { +export function ionicProviders(args={}) { let fastdom = new FastDom(); let app = new IonicApp(fastdom); diff --git a/ionic/config/test/config.spec.ts b/ionic/config/test/config.spec.ts index 6508442026..d751a51028 100644 --- a/ionic/config/test/config.spec.ts +++ b/ionic/config/test/config.spec.ts @@ -14,7 +14,7 @@ export function run() { let userConfig = new Config({ mode: 'configInstance' }) - let providers = ionicProviders(userConfig); + let providers = ionicProviders({config:userConfig}); let config = providers.find(provider => provider.useValue instanceof Config).useValue; @@ -22,9 +22,9 @@ export function run() { }); it('should create new Config instance from config object in ionicProviders', () => { - let providers = ionicProviders({ + let providers = ionicProviders({config: { mode: 'configObj' - }); + }}); let config = providers.find(provider => provider.useValue instanceof Config).useValue;