test(nav): clean up NavController tests

This commit is contained in:
Adam Bradley
2016-07-15 15:55:49 -05:00
parent 0a7d865975
commit 0386476879
13 changed files with 44 additions and 48 deletions

View File

@ -8,7 +8,6 @@ import { Form } from '../../util/form';
import { Item } from '../item/item'; import { Item } from '../item/item';
import { merge, isBlank, isPresent, isTrueProperty, isArray, isString } from '../../util/util'; import { merge, isBlank, isPresent, isTrueProperty, isArray, isString } from '../../util/util';
import { dateValueRange, renderDateTime, renderTextFormat, convertFormatToKey, getValueFromFormat, parseTemplate, parseDate, updateDate, DateTimeData, convertDataToISO, daysInMonth, dateSortValue, dateDataSortValue, LocaleData } from '../../util/datetime-util'; import { dateValueRange, renderDateTime, renderTextFormat, convertFormatToKey, getValueFromFormat, parseTemplate, parseDate, updateDate, DateTimeData, convertDataToISO, daysInMonth, dateSortValue, dateDataSortValue, LocaleData } from '../../util/datetime-util';
import { NavController } from '../nav/nav-controller';
export const DATETIME_VALUE_ACCESSOR = new Provider( export const DATETIME_VALUE_ACCESSOR = new Provider(
NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => DateTime), multi: true}); NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => DateTime), multi: true});

View File

@ -7,7 +7,7 @@ import {ionicBootstrap, InfiniteScroll, NavController} from '../../../../../src'
}) })
class E2EPage1 { class E2EPage1 {
@ViewChild(InfiniteScroll) infiniteScroll: InfiniteScroll; @ViewChild(InfiniteScroll) infiniteScroll: InfiniteScroll;
items = []; items: number[] = [];
enabled: boolean = true; enabled: boolean = true;
constructor(private nav: NavController) { constructor(private nav: NavController) {
@ -68,7 +68,7 @@ function getAsyncData(): Promise<any[]> {
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(() => { setTimeout(() => {
let data = []; let data: number[] = [];
for (var i = 0; i < 30; i++) { for (var i = 0; i < 30; i++) {
data.push(i); data.push(i);
} }

View File

@ -1,6 +1,6 @@
import { Component, Injectable } from '@angular/core'; import { Component, Injectable } from '@angular/core';
import { ActionSheetController, Config, ionicBootstrap, ModalController, NavController, NavParams, PageTransition, Platform, TransitionOptions, ViewController } from '../../../../../src'; import { ActionSheetController, App, Config, ionicBootstrap, ModalController, NavController, NavParams, PageTransition, Platform, TransitionOptions, ViewController } from '../../../../../src';
@Injectable() @Injectable()
@ -117,11 +117,11 @@ class E2EPage {
` `
}) })
class NavigableModal { class NavigableModal {
constructor(private navController:NavController) { constructor(private nav: NavController) {
} }
submit(){ submit(){
this.navController.push(NavigableModal2); this.nav.push(NavigableModal2);
} }
} }
@ -376,7 +376,7 @@ class ContactUs {
class ModalFirstPage { class ModalFirstPage {
private items:any[]; private items:any[];
constructor(private nav: NavController, private actionSheetCtrl: ActionSheetController) { constructor(private nav: NavController, private app: App, private actionSheetCtrl: ActionSheetController) {
this.items = []; this.items = [];
for ( let i = 0; i < 50; i++ ){ for ( let i = 0; i < 50; i++ ){
this.items.push({ this.items.push({
@ -393,7 +393,7 @@ class ModalFirstPage {
} }
dismiss() { dismiss() {
this.nav.rootNav.pop(); this.app.getRootNav().pop();
} }
ionViewLoaded(){ ionViewLoaded(){
@ -430,8 +430,8 @@ class ModalFirstPage {
// overlays are added and removed from the root navigation // overlays are added and removed from the root navigation
// find the root navigation, and pop this alert // find the root navigation, and pop this alert
// when the alert is done animating out, then pop off the modal // when the alert is done animating out, then pop off the modal
this.nav.rootNav.pop().then(() => { this.app.getRootNav().pop().then(() => {
this.nav.rootNav.pop(); this.app.getRootNav().pop();
}); });
// by default an alert will dismiss itself // by default an alert will dismiss itself

View File

@ -1,6 +1,6 @@
import { Component, ViewChild } from '@angular/core'; import { Component, ViewChild } from '@angular/core';
import { NavController, AlertController, Content } from '../../../../../src'; import { NavController, AlertController, Content } from '../../../../../src';
import { ionicBootstrap } from '../../../../../src'; import { ionicBootstrap, App } from '../../../../../src';
import { NavParams, ViewController } from '../../../../../src';; import { NavParams, ViewController } from '../../../../../src';;
@ -148,6 +148,7 @@ class FirstPage {
class FullPage { class FullPage {
constructor( constructor(
private nav: NavController, private nav: NavController,
private app: App,
private alertCtrl: AlertController, private alertCtrl: AlertController,
private params: NavParams private params: NavParams
) {} ) {}
@ -184,8 +185,8 @@ class FullPage {
// overlays are added and removed from the root navigation // overlays are added and removed from the root navigation
// ensure you using the root navigation, and pop this alert // ensure you using the root navigation, and pop this alert
// when the alert is done animating out, then pop off the active page // when the alert is done animating out, then pop off the active page
this.nav.rootNav.pop().then(() => { this.app.getRootNav().pop().then(() => {
this.nav.rootNav.pop(); this.app.getRootNav().pop();
}); });
// by default an alert will dismiss itself // by default an alert will dismiss itself

View File

@ -29,11 +29,11 @@ ionicBootstrap(E2EApp);
}) })
class LandingPage{ class LandingPage{
constructor(private _navController: NavController){ constructor(private nav: NavController){
} }
goToPage(){ goToPage(){
this._navController.push(FirstPage); this.nav.push(FirstPage);
} }
} }

View File

@ -16,7 +16,7 @@ let count = 0;
` `
}) })
class Page1 { class Page1 {
tmr; tmr: number;
constructor(private nav: NavController) {} constructor(private nav: NavController) {}
@ -50,7 +50,7 @@ class Page1 {
` `
}) })
class Page2 { class Page2 {
tmr; tmr: number;
constructor(private nav: NavController) {} constructor(private nav: NavController) {}

View File

@ -8,7 +8,7 @@ import {ionicBootstrap, NavController} from '../../../../../src';
class IntroPage { class IntroPage {
continueText: string = "Skip"; continueText: string = "Skip";
startingIndex: number = 1; startingIndex: number = 1;
mySlideOptions; mySlideOptions: any;
showSlide: boolean = true; showSlide: boolean = true;
constructor(private nav: NavController) { constructor(private nav: NavController) {
@ -20,16 +20,16 @@ class IntroPage {
}; };
} }
onSlideChanged(slider) { onSlideChanged(slider: any) {
console.log("Slide changed", slider); console.log('Slide changed', slider);
} }
onSlideChangeStart(slider) { onSlideChangeStart(slider: any) {
console.log("Slide change start", slider); console.log('Slide change start', slider);
slider.isEnd ? this.continueText = "Continue" : this.continueText = "Skip"; slider.isEnd ? this.continueText = 'Continue' : this.continueText = "Skip";
} }
onSlideMove(slider) { onSlideMove(slider: any) {
console.log("Slide move", slider); console.log("Slide move", slider);
} }

View File

@ -1,6 +1,6 @@
import { Component, ViewChild } from '@angular/core'; import { Component, ViewChild } from '@angular/core';
import { ionicBootstrap, NavController, NavParams, ModalController, ViewController, Tabs, Tab } from '../../../../../src'; import { App, ionicBootstrap, NavController, NavParams, ModalController, ViewController, Tabs, Tab } from '../../../../../src';
@Component({ @Component({
@ -92,7 +92,7 @@ class TabsPage {
class Tab1Page1 { class Tab1Page1 {
userId: string; userId: string;
constructor(private nav: NavController, private tabs: Tabs, private params: NavParams) { constructor(private nav: NavController, private app: App, private tabs: Tabs, private params: NavParams) {
this.userId = params.get('userId'); this.userId = params.get('userId');
} }
@ -102,7 +102,7 @@ class Tab1Page1 {
goBack() { goBack() {
console.log('go back begin'); console.log('go back begin');
this.nav.pop().then((val) => { this.nav.pop().then((val: any) => {
console.log('go back completed', val); console.log('go back completed', val);
});; });;
} }
@ -112,7 +112,7 @@ class Tab1Page1 {
} }
logout() { logout() {
this.nav.rootNav.setRoot(SignIn, null, { animate: true, direction: 'back' }); this.app.getRootNav().setRoot(SignIn, null, { animate: true, direction: 'back' });
} }
ionViewWillEnter() { ionViewWillEnter() {
@ -323,10 +323,8 @@ class Tab3Page1 {
@Component({ @Component({
template: '<ion-nav [root]="root" swipeBackEnabled="false"></ion-nav>' template: '<ion-nav swipeBackEnabled="false"></ion-nav>'
}) })
class E2EApp { class E2EApp {}
root = SignIn;
}
ionicBootstrap(E2EApp); ionicBootstrap(E2EApp);

View File

@ -1,5 +1,5 @@
import { Component} from '@angular/core'; import { Component} from '@angular/core';
import {ionicBootstrap, NavController, App, AlertController, ModalController, ViewController, Tab, Tabs} from '../../../../../src'; import { ionicBootstrap, App, AlertController, ModalController, ViewController, Tab, Tabs } from '../../../../../src';
// //
// Modal // Modal

View File

@ -4,7 +4,6 @@ import { NgIf } from '@angular/common';
import { Animation } from '../../animations/animation'; import { Animation } from '../../animations/animation';
import { Config } from '../../config/config'; import { Config } from '../../config/config';
import { isPresent } from '../../util/util'; import { isPresent } from '../../util/util';
import { NavController } from '../nav/nav-controller';
import { NavParams } from '../nav/nav-params'; import { NavParams } from '../nav/nav-params';
import { Transition, TransitionOptions } from '../../transitions/transition'; import { Transition, TransitionOptions } from '../../transitions/transition';
import { ViewController } from '../nav/view-controller'; import { ViewController } from '../nav/view-controller';
@ -44,7 +43,6 @@ export class ToastCmp implements AfterViewInit {
private id: number; private id: number;
constructor( constructor(
private _nav: NavController,
private _viewCtrl: ViewController, private _viewCtrl: ViewController,
private _config: Config, private _config: Config,
private _elementRef: ElementRef, private _elementRef: ElementRef,