chore(tests): add testing for disabled inputs

This commit is contained in:
Ken Sodemann
2018-02-06 11:32:51 -06:00
parent 77b8527d76
commit fcbe1818fa
4 changed files with 93 additions and 15 deletions

View File

@ -14,6 +14,30 @@ describe('Basic Inputs Page', () => {
expect(page.getTitleText()).toEqual('Ionic Core Basic Inputs Demo');
});
describe('search input', () => {
it('should display the starting text', () => {
page.navigateTo();
const el = page.getIonicSearchInput();
expect(el.getAttribute('value')).toEqual(null);
});
it('should reflect back the entered data', () => {
page.navigateTo();
const el = page.getIonicSearchInputEditable();
el.clear();
el.sendKeys('I am new text');
expect(page.getSearchOutput()).toEqual('I am new text');
});
// it('should disable', () => {
// page.navigateTo();
// const inp = page.getIonicSearchInputEditable();
// const cb = page.getDisableButton();
// cb.click();
// expect(inp.isEnabled()).toEqual(false);
// });
});
describe('text input', () => {
it('should display the starting text', () => {
page.navigateTo();
@ -40,6 +64,14 @@ describe('Basic Inputs Page', () => {
inp.sendKeys('X');
expect(hasClass(el, 'ng-invalid')).toEqual(false);
});
it('should disable', () => {
page.navigateTo();
const inp = page.getIonicTextInputEditable();
const cb = page.getDisableButton();
cb.click();
expect(inp.isEnabled()).toEqual(false);
});
});
describe('numeric input', () => {
@ -56,6 +88,14 @@ describe('Basic Inputs Page', () => {
inp.sendKeys('.48859');
expect(page.getNumericOutputType()).toEqual('number');
});
it('should disable', () => {
page.navigateTo();
const inp = page.getIonicNumericInputEditable();
const cb = page.getDisableButton();
cb.click();
expect(inp.isEnabled()).toEqual(false);
});
});
describe('textarea input', () => {
@ -84,6 +124,14 @@ describe('Basic Inputs Page', () => {
inp.sendKeys('X');
expect(hasClass(el, 'ng-invalid')).toEqual(false);
});
it('should disable', () => {
page.navigateTo();
const inp = page.getIonicTextareaInputEditable();
const cb = page.getDisableButton();
cb.click();
expect(inp.isEnabled()).toEqual(false);
});
});
describe('checkbox input', () => {

View File

@ -46,6 +46,19 @@ export class BasicInputsPage {
return element(by.id('textareaOutput')).getText();
}
getIonicSearchInput() {
return element(by.id('ionSearchInput'));
}
getIonicSearchInputEditable() {
const parent = this.getIonicSearchInput();
return parent.all(by.css('input')).first();
}
getSearchOutput() {
return element(by.id('searchOutput')).getText();
}
getIonicTextInput() {
return element(by.id('ionTextInput'));
}
@ -71,4 +84,8 @@ export class BasicInputsPage {
getNumericOutputType() {
return element(by.id('numericOutputType')).getText();
}
getDisableButton() {
return element(by.id('disableCheckbox'));
}
}