mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
35
angular/test/test-app/e2e/src/slides.e2e-spec.ts
Normal file
35
angular/test/test-app/e2e/src/slides.e2e-spec.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { browser, element, by } from 'protractor';
|
||||
import { handleErrorMessages, waitTime } from './utils';
|
||||
|
||||
describe('slides', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await browser.get('/slides');
|
||||
});
|
||||
afterEach(() => {
|
||||
handleErrorMessages();
|
||||
});
|
||||
|
||||
it('should change index on slide change', async () => {
|
||||
expect(await element(by.css('#slide-index')).getText()).toEqual('0');
|
||||
await nextSlide();
|
||||
|
||||
expect(await element(by.css('#slide-index')).getText()).toEqual('1');
|
||||
await nextSlide();
|
||||
|
||||
expect(await element(by.css('#slide-index')).getText()).toEqual('2');
|
||||
await prevSlide();
|
||||
|
||||
expect(await element(by.css('#slide-index')).getText()).toEqual('1');
|
||||
});
|
||||
});
|
||||
|
||||
async function nextSlide() {
|
||||
await element(by.css('#btn-next')).click();
|
||||
await waitTime(800);
|
||||
}
|
||||
|
||||
async function prevSlide() {
|
||||
await element(by.css('#btn-prev')).click();
|
||||
await waitTime(800);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import { NestedOutletPageComponent } from './nested-outlet-page/nested-outlet-pa
|
||||
import { NestedOutletPage2Component } from './nested-outlet-page2/nested-outlet-page2.component';
|
||||
import { ViewChildComponent } from './view-child/view-child.component';
|
||||
import { ProvidersComponent } from './providers/providers.component';
|
||||
import { SlidesComponent } from './slides/slides.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: HomePageComponent },
|
||||
@@ -25,6 +26,7 @@ const routes: Routes = [
|
||||
{ path: 'providers', component: ProvidersComponent },
|
||||
{ path: 'router-link', component: RouterLinkComponent },
|
||||
{ path: 'router-link-page', component: RouterLinkPageComponent },
|
||||
{ path: 'slides', component: SlidesComponent },
|
||||
{ path: 'virtual-scroll', component: VirtualScrollComponent },
|
||||
{ path: 'virtual-scroll-detail/:itemId', component: VirtualScrollDetailComponent },
|
||||
{ path: 'tabs', redirectTo: '/tabs/account', pathMatch: 'full' },
|
||||
|
||||
@@ -24,6 +24,7 @@ import { NestedOutletPage2Component } from './nested-outlet-page2/nested-outlet-
|
||||
import { NavComponent } from './nav/nav.component';
|
||||
import { ViewChildComponent } from './view-child/view-child.component';
|
||||
import { ProvidersComponent } from './providers/providers.component';
|
||||
import { SlidesComponent } from './slides/slides.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -46,7 +47,8 @@ import { ProvidersComponent } from './providers/providers.component';
|
||||
NestedOutletPage2Component,
|
||||
NavComponent,
|
||||
ViewChildComponent,
|
||||
ProvidersComponent
|
||||
ProvidersComponent,
|
||||
SlidesComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
||||
34
angular/test/test-app/src/app/slides/slides.component.html
Normal file
34
angular/test/test-app/src/app/slides/slides.component.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>
|
||||
Slides Test
|
||||
</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<ion-slides pager="true" (ionSlideDidChange)="checkIndex()">
|
||||
|
||||
<ion-slide>
|
||||
<h1>Slide 1</h1>
|
||||
</ion-slide>
|
||||
|
||||
<ion-slide>
|
||||
<h1>Slide 2</h1>
|
||||
</ion-slide>
|
||||
|
||||
<ion-slide>
|
||||
<h1>Slide 3</h1>
|
||||
</ion-slide>
|
||||
</ion-slides>
|
||||
|
||||
<p>
|
||||
index: <span id="slide-index">{{slideIndex}}</span>
|
||||
</p>
|
||||
|
||||
<ion-button id="btn-prev" (click)="prevSlide()">
|
||||
Prev Slide
|
||||
</ion-button>
|
||||
<ion-button id="btn-next" (click)="nextSlide()">
|
||||
Next Slide
|
||||
</ion-button>
|
||||
</ion-content>
|
||||
30
angular/test/test-app/src/app/slides/slides.component.ts
Normal file
30
angular/test/test-app/src/app/slides/slides.component.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { IonSlides } from '@ionic/angular';
|
||||
|
||||
@Component({
|
||||
selector: 'app-slides',
|
||||
templateUrl: './slides.component.html',
|
||||
})
|
||||
export class SlidesComponent implements OnInit {
|
||||
@ViewChild(IonSlides) slides: IonSlides;
|
||||
|
||||
slideIndex = 0;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
prevSlide() {
|
||||
this.slides.slidePrev();
|
||||
}
|
||||
|
||||
nextSlide() {
|
||||
this.slides.slideNext();
|
||||
}
|
||||
|
||||
async checkIndex() {
|
||||
this.slideIndex = await this.slides.getActiveIndex();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,6 @@
|
||||
"es2015": "dist/esm/es2017/index.js",
|
||||
"es2017": "dist/esm/es2017/index.js",
|
||||
"jsnext:main": "dist/esm/es2017/index.js",
|
||||
"sideEffects": false,
|
||||
"types": "dist/types/interface.d.ts",
|
||||
"collection": "dist/collection/collection-manifest.json",
|
||||
"webComponents": "dist/web-components.json",
|
||||
|
||||
Reference in New Issue
Block a user