test(e2e): searchbar/nav

This commit is contained in:
Daniel Imhoff
2017-03-06 12:27:58 -06:00
parent 2143f7198e
commit 6d8490e393
19 changed files with 252 additions and 158 deletions

View File

@@ -1,158 +0,0 @@
import { Component, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, ModalController, NavController, NavParams, ViewController } from '../../../..';
@Component({
templateUrl: 'main.html'
})
export class MainPage {
constructor(public navCtrl: NavController) { }
goToSecond() {
this.navCtrl.push(SearchPage);
}
}
@Component({
templateUrl: 'modal.html'
})
export class ModalPage {
constructor(public viewCtrl: ViewController) {}
close() {
this.viewCtrl.dismiss();
}
}
@Component({
templateUrl: 'search.html'
})
export class SearchPage {
items: string[];
constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
this.initializeItems();
}
showDetail(item: any) {
this.navCtrl.push(DetailPage, {city: item});
}
initializeItems() {
this.items = [
'Amsterdam',
'Bogota',
'Buenos Aires',
'Cairo',
'Dhaka',
'Edinburgh',
'Geneva',
'Genoa',
'Glasglow',
'Hanoi',
'Hong Kong',
'Islamabad',
'Istanbul',
'Jakarta',
'Kiel',
'Kyoto',
'Le Havre',
'Lebanon',
'Lhasa',
'Lima',
'London',
'Los Angeles',
'Madrid',
'Manila',
'New York',
'Olympia',
'Oslo',
'Panama City',
'Peking',
'Philadelphia',
'San Francisco',
'Seoul',
'Taipeh',
'Tel Aviv',
'Tokio',
'Uelzen',
'Washington'
];
}
getItems(ev: any) {
// Reset items back to all of the items
this.initializeItems();
// set q to the value of the searchbar
var q = ev.target.value;
// if the value is an empty string don't filter the items
if (!q || q.trim() === '') {
return;
}
this.items = this.items.filter((v) => {
if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
return true;
}
return false;
});
}
openModal() {
let modal = this.modalCtrl.create(ModalPage);
modal.present();
}
}
@Component({
templateUrl: 'detail.html'
})
export class DetailPage {
city: string;
constructor(private _navParams: NavParams) {
this.city = _navParams.get('city');
}
}
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
mainPage = MainPage;
searchPage = SearchPage;
}
@Component({
template: '<ion-nav [root]="root"></ion-nav>'
})
export class E2EApp {
root = TabsPage;
}
@NgModule({
declarations: [
E2EApp,
MainPage,
SearchPage,
ModalPage,
DetailPage,
TabsPage
],
imports: [
BrowserModule,
IonicModule.forRoot(E2EApp)
],
bootstrap: [IonicApp],
entryComponents: [
E2EApp,
MainPage,
SearchPage,
ModalPage,
DetailPage,
TabsPage
]
})
export class AppModule {}

View File

@@ -0,0 +1,8 @@
import { Component } from '@angular/core';
@Component({
template: '<ion-nav [root]="root"></ion-nav>'
})
export class E2EApp {
root = 'TabsPage';
}

View File

@@ -0,0 +1,28 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule } from '../../../../..';
import { E2EApp } from './app.component';
@NgModule({
declarations: [
E2EApp,
],
imports: [
BrowserModule,
IonicModule.forRoot(E2EApp, {}, {
links: [
{ loadChildren: '../pages/detail-page/detail.module#DetailPageModule', name: 'DetailPage' },
{ loadChildren: '../pages/main-page/main.module#MainPageModule', name: 'MainPage' },
{ loadChildren: '../pages/modal-page/modal.module#ModalPageModule', name: 'ModalPage' },
{ loadChildren: '../pages/search-page/search.module#SearchPageModule', name: 'SearchPage' },
{ loadChildren: '../pages/tabs-page/tabs.module#TabsPageModule', name: 'TabsPage' },
]
})
],
bootstrap: [IonicApp],
entryComponents: [
E2EApp,
]
})
export class AppModule {}

View File

@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { DetailPage } from './detail';
@NgModule({
declarations: [
DetailPage,
],
imports: [
DeepLinkModule.forChild(DetailPage)
],
entryComponents: [
DetailPage,
]
})
export class DetailPageModule {}

View File

@@ -0,0 +1,13 @@
import { Component } from '@angular/core';
import { NavParams } from '../../../../../..';
@Component({
templateUrl: 'detail.html'
})
export class DetailPage {
city: string;
constructor(private _navParams: NavParams) {
this.city = _navParams.get('city');
}
}

View File

@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { MainPage } from './main';
@NgModule({
declarations: [
MainPage,
],
imports: [
DeepLinkModule.forChild(MainPage)
],
entryComponents: [
MainPage,
]
})
export class MainPageModule {}

View File

@@ -0,0 +1,13 @@
import { Component } from '@angular/core';
import { NavController } from '../../../../../..';
@Component({
templateUrl: 'main.html'
})
export class MainPage {
constructor(public navCtrl: NavController) { }
goToSecond() {
this.navCtrl.push('SearchPage');
}
}

View File

@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { ModalPage } from './modal';
@NgModule({
declarations: [
ModalPage,
],
imports: [
DeepLinkModule.forChild(ModalPage)
],
entryComponents: [
ModalPage,
]
})
export class ModalPageModule {}

View File

@@ -0,0 +1,12 @@
import { Component } from '@angular/core';
import { ViewController } from '../../../../../..';
@Component({
templateUrl: 'modal.html'
})
export class ModalPage {
constructor(public viewCtrl: ViewController) {}
close() {
this.viewCtrl.dismiss();
}
}

View File

@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { SearchPage } from './search';
@NgModule({
declarations: [
SearchPage,
],
imports: [
DeepLinkModule.forChild(SearchPage)
],
entryComponents: [
SearchPage,
]
})
export class SearchPageModule {}

View File

@@ -0,0 +1,84 @@
import { Component } from '@angular/core';
import { NavController, ModalController } from '../../../../../..';
@Component({
templateUrl: 'search.html'
})
export class SearchPage {
items: string[];
constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
this.initializeItems();
}
showDetail(item: any) {
this.navCtrl.push('DetailPage', {city: item});
}
initializeItems() {
this.items = [
'Amsterdam',
'Bogota',
'Buenos Aires',
'Cairo',
'Dhaka',
'Edinburgh',
'Geneva',
'Genoa',
'Glasglow',
'Hanoi',
'Hong Kong',
'Islamabad',
'Istanbul',
'Jakarta',
'Kiel',
'Kyoto',
'Le Havre',
'Lebanon',
'Lhasa',
'Lima',
'London',
'Los Angeles',
'Madrid',
'Manila',
'New York',
'Olympia',
'Oslo',
'Panama City',
'Peking',
'Philadelphia',
'San Francisco',
'Seoul',
'Taipeh',
'Tel Aviv',
'Tokio',
'Uelzen',
'Washington'
];
}
getItems(ev: any) {
// Reset items back to all of the items
this.initializeItems();
// set q to the value of the searchbar
var q = ev.target.value;
// if the value is an empty string don't filter the items
if (!q || q.trim() === '') {
return;
}
this.items = this.items.filter((v) => {
if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
return true;
}
return false;
});
}
openModal() {
let modal = this.modalCtrl.create('ModalPage');
modal.present();
}
}

View File

@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { TabsPage } from './tabs';
@NgModule({
declarations: [
TabsPage,
],
imports: [
DeepLinkModule.forChild(TabsPage)
],
entryComponents: [
TabsPage,
]
})
export class TabsPageModule {}

View File

@@ -0,0 +1,9 @@
import { Component } from '@angular/core';
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
mainPage = 'MainPage';
searchPage = 'SearchPage';
}