Skip to content

Commit

Permalink
test(): update checkbox/select/toggle tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Feb 14, 2016
1 parent 78b1a0c commit 1e0df92
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ionic/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const CHECKBOX_VALUE_ACCESSOR = new Provider(
*
* <ion-item>
* <ion-label>Pepperoni</ion-label>
* <ion-checkbox [(ngModel)]="pepperoni" checked="true"></ion-checkbox>
* <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
* </ion-item>
*
* <ion-item>
Expand Down
2 changes: 1 addition & 1 deletion ionic/components/checkbox/test/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class E2EApp {

constructor() {
this.fruitsForm = new ControlGroup({
"appleCtrl": new Control(),
"appleCtrl": new Control(true),
"bananaCtrl": new Control(true),
"cherryCtrl": new Control(false),
"grapeCtrl": new Control(true)
Expand Down
8 changes: 8 additions & 0 deletions ionic/components/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,18 @@ export class Select {
* @private
*/
writeValue(val: any) {
console.debug('select, writeValue', val);
this._values = (Array.isArray(val) ? val : isBlank(val) ? [] : [val]);
this._updOpts();
}

/**
* @private
*/
ngAfterContentInit() {
this._updOpts();
}

/**
* @private
*/
Expand Down
13 changes: 11 additions & 2 deletions ionic/components/select/test/multiple-value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import {App, Page} from '../../../../../ionic/ionic';
templateUrl: 'main.html'
})
class E2EPage {
toppings: Array<string>;
carFeatures: Array<string>;
pets: Array<string>;
petOptions: Array<{text: string, value: string}>;

constructor() {
this.toppings = ['bacon', 'xcheese'];
this.carFeatures = [];
this.pets = ['cat', 'dog'];
this.petOptions = [
{ text: 'Bird', value: 'bird' },
{ text: 'Cat', value: 'cat', checked: true },
{ text: 'Dog', value: 'dog', checked: true },
{ text: 'Cat', value: 'cat' },
{ text: 'Dog', value: 'dog' },
{ text: 'Honey Badger', value: 'honeybadger' },
{ text: 'Pig', value: 'pig' },
];
Expand All @@ -27,6 +34,8 @@ class E2EPage {
template: '<ion-nav [root]="root"></ion-nav>'
})
class E2EApp {
root;

constructor() {
this.root = E2EPage;
}
Expand Down
6 changes: 3 additions & 3 deletions ionic/components/select/test/multiple-value/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<ion-item>
<ion-label>Toppings</ion-label>
<ion-select [(ngModel)]="toppings" multiple="true" cancelText="Nah" okText="Okay!" class="e2eSelectToppings">
<ion-option value="bacon" checked="true">Bacon</ion-option>
<ion-option value="bacon">Bacon</ion-option>
<ion-option value="olives">Black Olives</ion-option>
<ion-option value="xcheese" checked="true">Extra Cheese</ion-option>
<ion-option value="xcheese">Extra Cheese</ion-option>
<ion-option value="peppers">Green Peppers</ion-option>
<ion-option value="mushrooms">Mushrooms</ion-option>
<ion-option value="onions">Onions</ion-option>
Expand All @@ -35,7 +35,7 @@
<ion-item>
<ion-label>Pets</ion-label>
<ion-select [(ngModel)]="pets" multiple>
<ion-option *ngFor="#o of petOptions" [value]="o.value" [checked]="o.checked">{{o.text}}</ion-option>
<ion-option *ngFor="#o of petOptions" [value]="o.value">{{o.text}}</ion-option>
</ion-select>
</ion-item>

Expand Down
11 changes: 11 additions & 0 deletions ionic/components/select/test/single-value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ import {App, Page} from '../../../../../ionic/ionic';
class E2EPage {
musicAlertOpts;
gender: string;
gaming: string;
os: string;
music: string;
month: string;
year: string;

constructor() {
this.gaming = '';
this.os = 'win3.1';
this.music = null;
this.month = '12';
this.year = '1994';

this.musicAlertOpts = {
title: '1994 Music',
subTitle: 'Select your favorite'
Expand Down
6 changes: 3 additions & 3 deletions ionic/components/select/test/single-value/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<ion-option value="lunix">Linux</ion-option>
<ion-option value="mac7">Mac OS 7</ion-option>
<ion-option value="mac8">Mac OS 8</ion-option>
<ion-option value="win3.1" checked>Windows 3.1</ion-option>
<ion-option value="win3.1">Windows 3.1</ion-option>
<ion-option value="win95">Windows 95</ion-option>
<ion-option value="win98">Windows 98</ion-option>
</ion-select>
Expand Down Expand Up @@ -64,15 +64,15 @@
<ion-option value="09">September</ion-option>
<ion-option value="10">October</ion-option>
<ion-option value="11">November</ion-option>
<ion-option value="12" checked="true">December</ion-option>
<ion-option value="12">December</ion-option>
</ion-select>
<ion-select [(ngModel)]="year">
<ion-option>1989</ion-option>
<ion-option>1990</ion-option>
<ion-option>1991</ion-option>
<ion-option>1992</ion-option>
<ion-option>1993</ion-option>
<ion-option checked="true">1994</ion-option>
<ion-option>1994</ion-option>
<ion-option>1995</ion-option>
<ion-option>1996</ion-option>
<ion-option>1997</ion-option>
Expand Down
6 changes: 3 additions & 3 deletions ionic/components/toggle/test/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class E2EApp {

constructor() {
this.fruitsForm = new ControlGroup({
"appleCtrl": new Control(),
"appleCtrl": new Control(false),
"bananaCtrl": new Control(true),
"cherryCtrl": new Control(false),
"grapeCtrl": new Control(true)
Expand All @@ -33,8 +33,8 @@ class E2EApp {
this.grapeChecked = true;
this.grapeDisabled = true;

this.kiwiModel = false;
this.strawberryModel = true;
this.kiwiModel = true;
this.strawberryModel = false;
}

toggleGrapeChecked() {
Expand Down
2 changes: 1 addition & 1 deletion ionic/components/toggle/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const TOGGLE_VALUE_ACCESSOR = new Provider(
*
* <ion-item>
* <ion-label>Pepperoni</ion-label>
* <ion-toggle [(ngModel)]="pepperoni" checked="true"></ion-toggle>
* <ion-toggle [(ngModel)]="pepperoni"></ion-toggle>
* </ion-item>
*
* <ion-item>
Expand Down

0 comments on commit 1e0df92

Please sign in to comment.