mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 02:31:34 +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();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,11 @@
|
||||
<h2>Radio Buttons</h2>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<h3>Angular</h3>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<input id="stdBeef" type="radio" value="beef" [(ngModel)]="radioValue" />
|
||||
@ -26,35 +31,72 @@
|
||||
<span id="radioOutput">{{radioValue}}</span>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<h3>Ionic With Radio Group</h3>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<ion-list>
|
||||
<ion-radio-group [{ngModel}]="radioValue">
|
||||
<ion-radio-group id="radio-group" name="radio-group" [(ngModel)]="radioValue">
|
||||
<ion-item>
|
||||
<ion-label>Crarne Asada</ion-label>
|
||||
<ion-radio value="beef"></ion-radio>
|
||||
<ion-radio id="ion-grp-beef" name="ion-grp-beef" value="beef"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Lengua</ion-label>
|
||||
<ion-radio value="tongue"></ion-radio>
|
||||
<ion-radio id="ion-grp-tongue" name="ion-grp-tongue" value="tongue"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Sesos</ion-label>
|
||||
<ion-radio value="brains"></ion-radio>
|
||||
<ion-radio id="ion-grp-brains" name="ion-grp-brains" value="brains"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Tripa</ion-label>
|
||||
<ion-radio value="tripe"></ion-radio>
|
||||
<ion-radio id="ion-grp-tripe" name="ion-grp-tripe" value="tripe"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Pollo</ion-label>
|
||||
<ion-radio value="chicken"></ion-radio>
|
||||
<ion-radio id="ion-grp-chicken" name="ion-grp-chicken" value="chicken"></ion-radio>
|
||||
</ion-item>
|
||||
</ion-radio-group>
|
||||
</ion-list>
|
||||
</ion-col>
|
||||
<ion-col></ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<h3>Ionic Without Radio Group</h3>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<!-- <ion-row>
|
||||
<ion-col>
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
<ion-label>Crarne Asada</ion-label>
|
||||
<ion-radio value="beef" id="ion-beef" name="ion-beef" [(ngModel)]="radioValue"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Lengua</ion-label>
|
||||
<ion-radio value="tongue" id="ion-tongue" name="ion-tongue" [(ngModel)]="radioValue"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Sesos</ion-label>
|
||||
<ion-radio value="brains" id="ion-brains" name="ion-brains" [(ngModel)]="radioValue"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Tripa</ion-label>
|
||||
<ion-radio value="tripe" id="ion-tripe" name="ion-tripe" [(ngModel)]="radioValue"></ion-radio>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>Pollo</ion-label>
|
||||
<ion-radio value="chicken" id="ion-chicken" name="ion-chicken" [(ngModel)]="radioValue"></ion-radio>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-col>
|
||||
<ion-col></ion-col>
|
||||
</ion-row> -->
|
||||
|
||||
</ion-grid>
|
||||
<a href='home'>Home</a>
|
||||
|
Reference in New Issue
Block a user