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'; 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', () => { describe('textarea input', () => {
it('should display the starting text', () => { it('should display the starting text', () => {
page.navigateTo(); page.navigateTo();
@ -79,9 +95,11 @@ describe('Basic Inputs Page', () => {
it('should reflect toggling the value', () => { it('should reflect toggling the value', () => {
page.navigateTo(); page.navigateTo();
const el = page.getIonicCheckbox(); return browser.executeScript('window.scrollTo(0, 500);').then(function() {
el.click(); const el = page.getIonicCheckbox();
expect(page.getCheckboxOutput()).toEqual('false'); el.click();
expect(page.getCheckboxOutput()).toEqual('false');
});
}); });
}); });
@ -94,9 +112,11 @@ describe('Basic Inputs Page', () => {
it('should reflect toggling the value', () => { it('should reflect toggling the value', () => {
page.navigateTo(); page.navigateTo();
const el = page.getIonicToggle(); return browser.executeScript('window.scrollTo(0, 500);').then(function() {
el.click(); const el = page.getIonicToggle();
expect(page.getToggleOutput()).toEqual('true'); el.click();
expect(page.getToggleOutput()).toEqual('true');
});
}); });
}); });

View File

@ -55,7 +55,20 @@ export class BasicInputsPage {
return parent.all(by.css('input')).first(); 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() { getTextOutput() {
return element(by.id('textOutput')).getText(); return element(by.id('textOutput')).getText();
} }
getNumericOutputType() {
return element(by.id('numericOutputType')).getText();
}
} }

View File

@ -39,17 +39,17 @@
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-label>Ionic Numeric Input</ion-label> <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-item>
</ion-col> </ion-col>
<ion-col> <ion-col>
<div> <div>
Value: Value:
<span id="numberOutput">{{numberValue}}</span> <span id="numericOutput">{{numericValue}}</span>
</div> </div>
<div> <div>
Type: Type:
<span id="numberOutputType">{{typeOf(numberValue)}}</span> <span id="numericOutputType">{{typeOf(numericValue)}}</span>
</div> </div>
</ion-col> </ion-col>
</ion-row> </ion-row>

View File

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