-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(range): ionChange will only emit from user committed changes (#2…
- Loading branch information
1 parent
04ed860
commit d1fb7b0
Showing
21 changed files
with
328 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
describe('Form Controls: Range', () => { | ||
|
||
beforeEach(() => { | ||
cy.visit('/form-controls/range'); | ||
}); | ||
|
||
it('should have form control initial value', () => { | ||
// Cypress does not support checking numeric values of custom elements | ||
// see: https://github.com/cypress-io/cypress/blob/bf6560691436a5a953f7e03e0ea3de38f3d2a632/packages/driver/src/dom/elements/elementHelpers.ts#L7 | ||
cy.get('ion-range').invoke('prop', 'value').should('eq', 5); | ||
}); | ||
|
||
it('should reflect Ionic form control status classes', () => { | ||
// Control is initially invalid | ||
cy.get('ion-range').should('have.class', 'ion-invalid'); | ||
cy.get('ion-range').should('have.class', 'ion-pristine'); | ||
cy.get('ion-range').should('have.class', 'ion-untouched'); | ||
|
||
// Cypress does not support typing unless the element is focusable. | ||
cy.get('ion-range').shadow() | ||
.find('.range-knob-handle') | ||
.click() | ||
.focus() | ||
.type('{rightarrow}'.repeat(5)); | ||
|
||
cy.get('ion-range').should('have.class', 'ion-valid'); | ||
cy.get('ion-range').should('have.class', 'ion-dirty'); | ||
cy.get('ion-range').should('have.class', 'ion-touched'); | ||
cy.get('ion-range').invoke('prop', 'value').should('eq', 10); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
angular/test/base/src/app/form-controls/range/range-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
import { RangeComponent } from './range.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
RouterModule.forChild([ | ||
{ path: '', component: RangeComponent } | ||
]) | ||
] | ||
}) | ||
export class RangeRoutingModule { } |
16 changes: 16 additions & 0 deletions
16
angular/test/base/src/app/form-controls/range/range.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>Range</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content> | ||
<form [formGroup]="form"> | ||
<ion-list> | ||
<ion-item> | ||
<ion-label>Range</ion-label> | ||
<ion-range formControlName="range" min="0" max="20"></ion-range> | ||
</ion-item> | ||
</ion-list> | ||
<ion-button type="submit">Submit</ion-button> | ||
</form> | ||
</ion-content> |
18 changes: 18 additions & 0 deletions
18
angular/test/base/src/app/form-controls/range/range.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-range', | ||
templateUrl: './range.component.html' | ||
}) | ||
export class RangeComponent { | ||
|
||
form: FormGroup; | ||
|
||
constructor(private fb: FormBuilder) { | ||
this.form = this.fb.group({ | ||
range: [5, Validators.min(10)] | ||
}); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
angular/test/base/src/app/form-controls/range/range.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { RangeRoutingModule } from './range-routing.module'; | ||
import { RangeComponent } from './range.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
FormsModule, | ||
ReactiveFormsModule, | ||
IonicModule, | ||
RangeRoutingModule | ||
], | ||
declarations: [ | ||
RangeComponent | ||
] | ||
}) | ||
export class RangeModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.