chore(all): fix tests

This commit is contained in:
Manu Mtz.-Almeida
2018-09-25 00:03:14 +02:00
parent b3aebb843c
commit 5b3f0c326c
13 changed files with 37 additions and 34 deletions

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: alertFromActionSheet', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/alert-from-action-sheet?ionic:animate=false`
url: `/src/components/action-sheet/test/alert-from-action-sheet?ionic:animated=false`
});
const presentBtn = await page.find('#alertFromActionSheet');
presentBtn.click();
await presentBtn.click();
const actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();
@ -15,7 +15,7 @@ it('action-sheet: alertFromActionSheet', async () => {
expect(compare).toMatchScreenshot();
const openAlertBtn = await page.find({ text: 'Open Alert' });
openAlertBtn.click();
await openAlertBtn.click();
const alert = await page.find('ion-alert');
await alert.waitForVisible();
@ -24,11 +24,5 @@ it('action-sheet: alertFromActionSheet', async () => {
expect(compare).toMatchScreenshot();
const alertOkayBtn = await page.find({ contains: 'Okay' });
alertOkayBtn.click();
await Promise.all([
alert.waitForNotVisible(),
actionSheet.waitForNotVisible()
]);
await alertOkayBtn.click();
});

View File

@ -11,6 +11,8 @@
<body>
<ion-app>
<ion-action-sheet-controller></ion-action-sheet-controller>
<ion-alert-controller></ion-alert-controller>
<ion-header>
<ion-toolbar>
@ -19,8 +21,6 @@
</ion-header>
<ion-content padding>
<ion-action-sheet-controller></ion-action-sheet-controller>
<ion-alert-controller></ion-alert-controller>
<ion-button expand="block" id="alertFromActionSheet" onclick="presentAlert()">Alert from Action Sheet</ion-button>
@ -46,6 +46,7 @@
text: 'Okay',
handler: async () => {
await actionSheetElement.dismiss();
return false;
}
}]
});

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: basic', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/basic?ionic:animate=false`
url: `/src/components/action-sheet/test/basic?ionic:animated=false`
});
const presentBtn = await page.find('#basic');
presentBtn.click();
await presentBtn.click();
let actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();
@ -15,9 +15,9 @@ it('action-sheet: basic', async () => {
expect(compare).toMatchScreenshot();
const backdrop = await page.find('ion-backdrop');
backdrop.click();
await backdrop.click();
await actionSheet.waitForNotVisible();
await actionSheet.callMethod('onDidDismiss');
compare = await page.compareScreenshot(`dismissed`);
expect(compare).toMatchScreenshot();

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: cancelOnly', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/cancel-only?ionic:animate=false`
url: `/src/components/action-sheet/test/cancel-only?ionic:animated=false`
});
const presentBtn = await page.find('#cancelOnly');
presentBtn.click();
await presentBtn.click();
const actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: cssClass', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/custom-css?ionic:animate=false`
url: `/src/components/action-sheet/test/custom-css?ionic:animated=false`
});
const presentBtn = await page.find('#cssClass');
presentBtn.click();
await presentBtn.click();
const actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: icons', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/icons?ionic:animate=false`
url: `/src/components/action-sheet/test/icons?ionic:animated=false`
});
const presentBtn = await page.find('#icons');
presentBtn.click();
await presentBtn.click();
const actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: noBackdropDismiss', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/no-backdrop-dismiss?ionic:animate=false`
url: `/src/components/action-sheet/test/no-backdrop-dismiss?ionic:animated=false`
});
const presentBtn = await page.find('#noBackdropDismiss');
presentBtn.click();
await presentBtn.click();
let actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();
@ -15,7 +15,7 @@ it('action-sheet: noBackdropDismiss', async () => {
expect(compare).toMatchScreenshot();
const backdrop = await page.find('ion-backdrop');
backdrop.click();
await backdrop.click();
compare = await page.compareScreenshot(`dismissed`);
expect(compare).toMatchScreenshot();
@ -24,7 +24,7 @@ it('action-sheet: noBackdropDismiss', async () => {
expect(isVisible).toBe(true);
const cancel = await page.find('.action-sheet-cancel');
cancel.click();
await cancel.click();
await actionSheet.waitForNotVisible();

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: scrollWithoutCancel', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/scroll-without-cancel?ionic:animate=false`
url: `/src/components/action-sheet/test/scroll-without-cancel?ionic:animated=false`
});
const presentBtn = await page.find('#scrollWithoutCancel');
presentBtn.click();
await presentBtn.click();
const actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();

View File

@ -2,11 +2,11 @@ import { newE2EPage } from '@stencil/core/testing';
it('action-sheet: scrollableOptions', async () => {
const page = await newE2EPage({
url: `/src/components/action-sheet/test/scrollable-options?ionic:animate=false`
url: `/src/components/action-sheet/test/scrollable-options?ionic:animated=false`
});
const presentBtn = await page.find('#scrollableOptions');
presentBtn.click();
await presentBtn.click();
const actionSheet = await page.find('ion-action-sheet');
await actionSheet.waitForVisible();

View File

@ -1,6 +1,6 @@
import { Component, ComponentInterface, Method } from '@stencil/core';
import { Component, ComponentInterface, Method, Prop } from '@stencil/core';
import { Animation, AnimationBuilder, AnimationController } from '../../interface';
import { Animation, AnimationBuilder, AnimationController, Config } from '../../interface';
import { Animator } from './animator';
@ -10,11 +10,14 @@ import { Animator } from './animator';
})
export class AnimationControllerImpl implements ComponentInterface, AnimationController {
@Prop({ context: 'config' }) config!: Config;
/**
* Creates an animation instance
*/
@Method()
create(animationBuilder?: AnimationBuilder, baseEl?: any, opts?: any): Promise<Animation> {
Animator.animated = this.config.getBoolean('animated', true);
if (animationBuilder) {
return animationBuilder(Animator as any, baseEl, opts);
}

View File

@ -31,6 +31,8 @@ const raf = (window as any).requestAnimationFrame
export class Animator {
static animated = true;
private _afterAddClasses?: string[];
private _afterRemoveClasses?: string[];
private _afterStyles?: { [property: string]: any; };
@ -98,7 +100,7 @@ export class Animator {
* not have a duration, then it'll get the duration from its parent.
*/
getDuration(opts?: PlayOptions): number {
if (!location.search.includes('ionic:animate=false')) {
if (Animator.animated) {
if (opts && opts.duration !== undefined) {
return opts.duration;
} else if (this._duration !== undefined) {

View File

@ -50,6 +50,7 @@ export class Backdrop implements ComponentInterface {
this.emitTap(ev);
}
@Listen('click', { passive: false, capture: true })
@Listen('mousedown', { passive: false, capture: true })
protected onMouseDown(ev: TouchEvent) {
if (this.lastClick < now(ev) - 2500) {

View File

@ -1,5 +1,6 @@
import { Component, ComponentInterface, Element, Method, Prop, QueueApi } from '@stencil/core';
import { Config } from '../../interface';
import { rIC } from '../../utils/helpers';
@Component({
@ -13,13 +14,14 @@ export class RippleEffect implements ComponentInterface {
@Prop({ context: 'queue' }) queue!: QueueApi;
@Prop({ context: 'window' }) win!: Window;
@Prop({ context: 'config' }) config!: Config;
/**
* Adds the ripple effect to the parent element
*/
@Method()
addRipple(pageX: number, pageY: number) {
if (!location.search.includes('ionic:animate=false')) {
if (this.config.getBoolean('animated', true)) {
rIC(() => this.prepareRipple(pageX, pageY));
}
}