feat(numeric-input): create e2e test case

This commit is contained in:
Ken Sodemann
2017-12-11 14:17:51 -06:00
parent 8b6a1826a3
commit 6069549792
4 changed files with 44 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import { ElementFinder, promise } from 'protractor/built';
import { browser, ElementFinder, promise } from 'protractor/built';
import { BasicInputsPage } from './basic-inputs.po';
@ -42,6 +42,22 @@ describe('Basic Inputs Page', () => {
});
});
describe('numeric input', () => {
it('should remain type number with modifications', () => {
page.navigateTo();
const el = page.getIonicNumericInput();
const inp = page.getIonicNumericInputEditable();
expect(page.getNumericOutputType()).toEqual('number');
inp.sendKeys('318');
expect(page.getNumericOutputType()).toEqual('number');
inp.clear();
inp.sendKeys('-0');
expect(page.getNumericOutputType()).toEqual('number');
inp.sendKeys('.48859');
expect(page.getNumericOutputType()).toEqual('number');
});
});
describe('textarea input', () => {
it('should display the starting text', () => {
page.navigateTo();
@ -79,9 +95,11 @@ describe('Basic Inputs Page', () => {
it('should reflect toggling the value', () => {
page.navigateTo();
const el = page.getIonicCheckbox();
el.click();
expect(page.getCheckboxOutput()).toEqual('false');
return browser.executeScript('window.scrollTo(0, 500);').then(function() {
const el = page.getIonicCheckbox();
el.click();
expect(page.getCheckboxOutput()).toEqual('false');
});
});
});
@ -94,9 +112,11 @@ describe('Basic Inputs Page', () => {
it('should reflect toggling the value', () => {
page.navigateTo();
const el = page.getIonicToggle();
el.click();
expect(page.getToggleOutput()).toEqual('true');
return browser.executeScript('window.scrollTo(0, 500);').then(function() {
const el = page.getIonicToggle();
el.click();
expect(page.getToggleOutput()).toEqual('true');
});
});
});

View File

@ -55,7 +55,20 @@ export class BasicInputsPage {
return parent.all(by.css('input')).first();
}
getIonicNumericInput() {
return element(by.id('ionNumericInput'));
}
getIonicNumericInputEditable() {
const parent = this.getIonicNumericInput();
return parent.all(by.css('input')).first();
}
getTextOutput() {
return element(by.id('textOutput')).getText();
}
getNumericOutputType() {
return element(by.id('numericOutputType')).getText();
}
}

View File

@ -39,17 +39,17 @@
<ion-col>
<ion-item>
<ion-label>Ionic Numeric Input</ion-label>
<ion-input type="number" id="ionNumberInput" name="ionNumberInput" [(ngModel)]="numberValue"></ion-input>
<ion-input type="number" id="ionNumericInput" name="ionNumericInput" [(ngModel)]="numericValue"></ion-input>
</ion-item>
</ion-col>
<ion-col>
<div>
Value:
<span id="numberOutput">{{numberValue}}</span>
<span id="numericOutput">{{numericValue}}</span>
</div>
<div>
Type:
<span id="numberOutputType">{{typeOf(numberValue)}}</span>
<span id="numericOutputType">{{typeOf(numericValue)}}</span>
</div>
</ion-col>
</ion-row>

View File

@ -10,7 +10,7 @@ export class BasicInputsPageComponent implements OnInit {
datetimeValue = '2017-11-18T14:17:45-06:00';
textareaValue = 'This is the Textarea Input';
textValue = 'This is the Text Input';
numberValue = 1138;
numericValue = 1138;
checkboxValue = true;
toggleValue = false;