mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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', () => {
|
||||
|
@ -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', () => {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user