fix(popTo): fix reference and tests

Closes #511
This commit is contained in:
Adam Bradley
2015-11-13 17:12:15 -06:00
parent d5ac78f7b0
commit 050b600940
6 changed files with 55 additions and 8 deletions

View File

@ -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.

View File

@ -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);
}
/**

View File

@ -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', () => {

View File

@ -18,7 +18,7 @@ export function run() {
it('should be activatable on <ion-item-sliding> 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 <ion-item> element', () => {