mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 23:58:13 +08:00
feat(demo): test out the radio button group
This commit is contained in:
@ -13,4 +13,41 @@ describe('Group Inputs Page', () => {
|
||||
page.navigateTo();
|
||||
expect(page.getTitleText()).toEqual('Ionic Core Group Inputs Demo');
|
||||
});
|
||||
|
||||
describe('radio group', () => {
|
||||
it('should have the proper initial value', () => {
|
||||
page.navigateTo();
|
||||
const el = page.getRaioGroup();
|
||||
expect(el.getAttribute('value')).toEqual('tripe');
|
||||
});
|
||||
|
||||
// This test is failing right now, you can also see this in the UI.
|
||||
it('should check the proper initial radio button', () => {
|
||||
page.navigateTo();
|
||||
const btns = page.getGroupedRadioButtons();
|
||||
expect(btns.tripe.getAttribute('checked')).toEqual('true');
|
||||
expect(btns.beef.getAttribute('checked')).toEqual(null);
|
||||
expect(btns.chicken.getAttribute('checked')).toEqual(null);
|
||||
expect(btns.brains.getAttribute('checked')).toEqual(null);
|
||||
expect(btns.tongue.getAttribute('checked')).toEqual(null);
|
||||
});
|
||||
|
||||
it('should reflect back the changed value', () => {
|
||||
page.navigateTo();
|
||||
const btns = page.getGroupedRadioButtons();
|
||||
btns.chicken.click();
|
||||
expect(page.getRadioOutputText()).toEqual('chicken');
|
||||
});
|
||||
|
||||
it('should check and uncheck the proper buttons on a changed value', () => {
|
||||
page.navigateTo();
|
||||
const btns = page.getGroupedRadioButtons();
|
||||
btns.chicken.click();
|
||||
expect(btns.chicken.getAttribute('checked')).toEqual('true');
|
||||
expect(btns.beef.getAttribute('checked')).toEqual(null);
|
||||
expect(btns.tripe.getAttribute('checked')).toEqual(null);
|
||||
expect(btns.brains.getAttribute('checked')).toEqual(null);
|
||||
expect(btns.tongue.getAttribute('checked')).toEqual(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,15 +5,35 @@ export class GroupInputsPage {
|
||||
return browser.get('/group-inputs');
|
||||
}
|
||||
|
||||
getIonicCheckbox() {
|
||||
return element(by.id('ionCheckbox'));
|
||||
}
|
||||
|
||||
getCheckboxOutput() {
|
||||
return element(by.id('checkboxOutput')).getText();
|
||||
}
|
||||
|
||||
getTitleText() {
|
||||
return element(by.css('.title')).getText();
|
||||
}
|
||||
|
||||
getRaioGroup() {
|
||||
return element(by.id('radio-group'));
|
||||
}
|
||||
|
||||
getGroupedRadioButtons() {
|
||||
return {
|
||||
beef: element(by.id('ion-grp-beef')),
|
||||
tongue: element(by.id('ion-grp-tongue')),
|
||||
brains: element(by.id('ion-grp-brains')),
|
||||
tripe: element(by.id('ion-grp-tripe')),
|
||||
chicken: element(by.id('ion-grp-chicken'))
|
||||
};
|
||||
}
|
||||
|
||||
getUngroupedRadioButtons() {
|
||||
return {
|
||||
beef: element(by.id('ion-beef')),
|
||||
tongue: element(by.id('ion-tongue')),
|
||||
brains: element(by.id('ion-brains')),
|
||||
tripe: element(by.id('ion-tripe')),
|
||||
chicken: element(by.id('ion-chicken'))
|
||||
};
|
||||
}
|
||||
|
||||
getRadioOutputText() {
|
||||
return element(by.id('radioOutput')).getText();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,11 +9,11 @@ describe('Demo Home Page', () => {
|
||||
|
||||
it('should display title', () => {
|
||||
page.navigateTo();
|
||||
expect(page.getTitle()).toEqual('Ionic Core Angular Demo Application');
|
||||
expect(page.getTitleText()).toEqual('Ionic Core Angular Demo Application');
|
||||
});
|
||||
|
||||
it('should navigate to home for root', () => {
|
||||
page.navigateToRoot();
|
||||
expect(page.getTitle()).toEqual('Ionic Core Angular Demo Application');
|
||||
expect(page.getTitleText()).toEqual('Ionic Core Angular Demo Application');
|
||||
});
|
||||
});
|
||||
|
||||
@ -9,7 +9,7 @@ export class HomePage {
|
||||
return browser.get('/');
|
||||
}
|
||||
|
||||
getTitle() {
|
||||
getTitleText() {
|
||||
return element(by.css('.title')).getText();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user