mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(e2e): refactor e2e to use deeplink decorator, lazy load more pages
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { PageOne } from '../pages/page-one/page-one';
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = 'E2EPage';
|
||||
export class AppComponent {
|
||||
rootPage = PageOne;
|
||||
}
|
||||
|
||||
@@ -2,27 +2,18 @@ import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IonicApp, IonicModule } from '../../../../..';
|
||||
|
||||
import { E2EApp } from './app.component';
|
||||
import { AppComponent } from './app.component';
|
||||
import { PageOneModule } from '../pages/page-one/page-one.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
AppComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(E2EApp, {}, {
|
||||
links: [
|
||||
{ loadChildren: '../pages/main/main.module#E2EPageModule', name: 'E2EPage' },
|
||||
{ loadChildren: '../pages/page1/page1.module#Page1Module', name: 'Page1' },
|
||||
{ loadChildren: '../pages/page2/page2.module#Page2Module', name: 'Page2' },
|
||||
{ loadChildren: '../pages/page3/page3.module#Page3Module', name: 'Page3' },
|
||||
{ loadChildren: '../components/modal/modal.module#ModalModule', name: 'Modal' },
|
||||
]
|
||||
})
|
||||
IonicModule.forRoot(AppComponent, {}),
|
||||
PageOneModule
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EApp,
|
||||
]
|
||||
bootstrap: [IonicApp]
|
||||
})
|
||||
export class AppModule { }
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ViewController } from '../../../../../..';
|
||||
|
||||
@Component({ templateUrl: 'modal.html' })
|
||||
export class Modal {
|
||||
constructor(public viewController: ViewController) { }
|
||||
close() {
|
||||
this.viewController.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { E2EPage } from './main';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EPage,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(E2EPage)
|
||||
],
|
||||
entryComponents: [
|
||||
E2EPage,
|
||||
]
|
||||
})
|
||||
export class E2EPageModule {}
|
||||
@@ -1,17 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { Modal } from './modal';
|
||||
import { ModalPage } from './modal-page';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
Modal,
|
||||
ModalPage,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(Modal)
|
||||
],
|
||||
entryComponents: [
|
||||
Modal,
|
||||
DeepLinkModule.forChild(ModalPage)
|
||||
]
|
||||
})
|
||||
export class ModalModule {}
|
||||
export class ModalPageModule {}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { DeepLink, ViewController } from '../../../../../..';
|
||||
|
||||
@DeepLink()
|
||||
@Component({
|
||||
templateUrl: 'modal-page.html'
|
||||
})
|
||||
export class ModalPage {
|
||||
constructor(public viewController: ViewController) {
|
||||
}
|
||||
|
||||
close() {
|
||||
this.viewController.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { Page2 } from './page2';
|
||||
import { PageFour } from './page-four';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
Page2,
|
||||
PageFour,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(Page2)
|
||||
],
|
||||
entryComponents: [
|
||||
Page2,
|
||||
DeepLinkModule.forChild(PageFour)
|
||||
]
|
||||
})
|
||||
export class Page2Module {}
|
||||
export class PageFourModule {}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { DeepLink } from '../../../../../..';
|
||||
|
||||
@DeepLink()
|
||||
@Component({
|
||||
templateUrl: 'page-four.html'
|
||||
})
|
||||
export class PageFour { }
|
||||
@@ -0,0 +1,16 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { PageOne } from './page-one';
|
||||
import { PageTwoModule } from '../page-two/page-two.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
PageOne,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(PageOne),
|
||||
PageTwoModule
|
||||
]
|
||||
})
|
||||
export class PageOneModule {}
|
||||
@@ -1,23 +1,25 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { MenuController, Nav } from '../../../../../..';
|
||||
import { DeepLink, MenuController, Nav } from '../../../../../..';
|
||||
|
||||
import { PageTwo } from '../page-two/page-two';
|
||||
|
||||
@DeepLink()
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
templateUrl: 'page-one.html'
|
||||
})
|
||||
export class E2EPage {
|
||||
export class PageOne {
|
||||
rootPage: any;
|
||||
changeDetectionCount: number = 0;
|
||||
pages: Array<{ title: string, component: any }>;
|
||||
@ViewChild(Nav) nav: Nav;
|
||||
|
||||
constructor(public menuCtrl: MenuController) {
|
||||
this.rootPage = 'Page1';
|
||||
this.rootPage = PageTwo;
|
||||
|
||||
this.pages = [
|
||||
{ title: 'Page 1', component: 'Page1' },
|
||||
{ title: 'Page 2', component: 'Page2' },
|
||||
{ title: 'Page 3', component: 'Page3' },
|
||||
{ title: 'Page 1', component: PageTwo },
|
||||
{ title: 'Page 2', component: 'PageThree' },
|
||||
{ title: 'Page 3', component: 'PageFour' },
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { Page3 } from './page3';
|
||||
import { PageThree } from './page-three';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
Page3,
|
||||
PageThree,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(Page3)
|
||||
],
|
||||
entryComponents: [
|
||||
Page3,
|
||||
DeepLinkModule.forChild(PageThree)
|
||||
]
|
||||
})
|
||||
export class Page3Module {}
|
||||
export class PageThreeModule {}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { DeepLink, NavController } from '../../../../../..';
|
||||
|
||||
@DeepLink()
|
||||
@Component({
|
||||
templateUrl: 'page-three.html'
|
||||
})
|
||||
export class PageThree {
|
||||
constructor(public navCtrl: NavController) { }
|
||||
|
||||
page3() {
|
||||
this.navCtrl.push('PageFour');
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { Page1 } from './page1';
|
||||
import { PageTwo } from './page-two';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
Page1,
|
||||
PageTwo,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(Page1)
|
||||
],
|
||||
entryComponents: [
|
||||
Page1,
|
||||
DeepLinkModule.forChild(PageTwo)
|
||||
]
|
||||
})
|
||||
export class Page1Module {}
|
||||
export class PageTwoModule {}
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { AlertController, ModalController, NavController } from '../../../../../..';
|
||||
import { AlertController, DeepLink, ModalController, NavController } from '../../../../../..';
|
||||
|
||||
@DeepLink()
|
||||
@Component({
|
||||
templateUrl: 'page1.html'
|
||||
templateUrl: 'page-two.html'
|
||||
})
|
||||
export class Page1 {
|
||||
export class PageTwo {
|
||||
constructor(
|
||||
public navCtrl: NavController,
|
||||
public alertCtrl: AlertController,
|
||||
@@ -23,11 +24,11 @@ export class Page1 {
|
||||
}
|
||||
|
||||
presentModal() {
|
||||
let modal = this.modalCtrl.create('Modal');
|
||||
let modal = this.modalCtrl.create('ModalPage');
|
||||
modal.present();
|
||||
}
|
||||
|
||||
goToPage2() {
|
||||
this.navCtrl.push('Page2');
|
||||
this.navCtrl.push('PageThree');
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { NavController } from '../../../../../..';
|
||||
|
||||
@Component({ templateUrl: 'page2.html' })
|
||||
export class Page2 {
|
||||
constructor(public navCtrl: NavController) { }
|
||||
|
||||
page3() {
|
||||
this.navCtrl.push('Page3');
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({ templateUrl: 'page3.html' })
|
||||
export class Page3 { }
|
||||
Reference in New Issue
Block a user