mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
feat(demo): test out validations
This commit is contained in:
@ -1,3 +1,5 @@
|
|||||||
|
import { ElementFinder, promise } from 'protractor/built';
|
||||||
|
|
||||||
import { InputsPage } from './inputs.po';
|
import { InputsPage } from './inputs.po';
|
||||||
|
|
||||||
describe('Demo Inputs Page', () => {
|
describe('Demo Inputs Page', () => {
|
||||||
@ -26,6 +28,18 @@ describe('Demo Inputs Page', () => {
|
|||||||
el.sendKeys('I am new text');
|
el.sendKeys('I am new text');
|
||||||
expect(page.getIonicTextInputOutputText()).toEqual('I am new text');
|
expect(page.getIonicTextInputOutputText()).toEqual('I am new text');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should trigger validation errors', () => {
|
||||||
|
page.navigateTo();
|
||||||
|
const el = page.getIonicTextInput();
|
||||||
|
const inp = page.getIonicTextInputEditable();
|
||||||
|
expect(hasClass(el, 'ng-invalid')).toEqual(false);
|
||||||
|
inp.clear();
|
||||||
|
inp.sendKeys('ninechars');
|
||||||
|
expect(hasClass(el, 'ng-invalid')).toEqual(true);
|
||||||
|
inp.sendKeys('X');
|
||||||
|
expect(hasClass(el, 'ng-invalid')).toEqual(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('textarea input', () => {
|
describe('textarea input', () => {
|
||||||
@ -42,6 +56,18 @@ describe('Demo Inputs Page', () => {
|
|||||||
el.sendKeys('I am new text');
|
el.sendKeys('I am new text');
|
||||||
expect(page.getIonicTextareaInputOutputText()).toEqual('I am new text');
|
expect(page.getIonicTextareaInputOutputText()).toEqual('I am new text');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should trigger validation errors', () => {
|
||||||
|
page.navigateTo();
|
||||||
|
const el = page.getIonicTextareaInput();
|
||||||
|
const inp = page.getIonicTextareaInputEditable();
|
||||||
|
expect(hasClass(el, 'ng-invalid')).toEqual(false);
|
||||||
|
inp.clear();
|
||||||
|
inp.sendKeys('ninechars');
|
||||||
|
expect(hasClass(el, 'ng-invalid')).toEqual(true);
|
||||||
|
inp.sendKeys('X');
|
||||||
|
expect(hasClass(el, 'ng-invalid')).toEqual(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('checkbox input', () => {
|
describe('checkbox input', () => {
|
||||||
@ -73,4 +99,9 @@ describe('Demo Inputs Page', () => {
|
|||||||
expect(page.getIonicToggleOutputText()).toEqual('true');
|
expect(page.getIonicToggleOutputText()).toEqual('true');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function hasClass(el: ElementFinder, cls: string): Promise<boolean> {
|
||||||
|
const classes = await el.getAttribute('class');
|
||||||
|
return classes.split(' ').indexOf(cls) !== -1;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<label for="stdTextInput">Standard Input</label>
|
<label for="stdTextInput">Standard Input</label>
|
||||||
<input id="stdTextInput" name="stdTextInput" [(ngModel)]="stdTextInput" />
|
<input id="stdTextInput" name="stdTextInput" [(ngModel)]="stdTextInput" minlength="10"/>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
Standard Text Input:
|
Standard Text Input:
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<ion-col>
|
<ion-col>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Ionic Text Input</ion-label>
|
<ion-label>Ionic Text Input</ion-label>
|
||||||
<ion-input id="ionTextInput" name="ionTextInput" [(ngModel)]="ionTextInput" (ionBlur)="onBlur($event)"></ion-input>
|
<ion-input id="ionTextInput" name="ionTextInput" [(ngModel)]="ionTextInput" minlength="10" (ionBlur)="onBlur($event)"></ion-input>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<ion-col>
|
<ion-col>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Ionic Text Area Input</ion-label>
|
<ion-label>Ionic Text Area Input</ion-label>
|
||||||
<ion-textarea id="ionTextareaInput" name="ionTextareaInput" [(ngModel)]="ionTextareaInput" (ionBlur)="onBlur($event)"></ion-textarea>
|
<ion-textarea id="ionTextareaInput" name="ionTextareaInput" [(ngModel)]="ionTextareaInput" minlength="10" (ionBlur)="onBlur($event)"></ion-textarea>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
|
|||||||
Reference in New Issue
Block a user