Skip to content

Commit

Permalink
Safari 8 does not report input validity in forms, so the tests fail f…
Browse files Browse the repository at this point in the history
…or it..
  • Loading branch information
devversion committed Aug 31, 2016
1 parent ba76aa9 commit 823307e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib/slide-toggle/slide-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ describe('MdSlideToggle', () => {
let testComponent: SlideToggleFormsTestApp;
let buttonElement: HTMLButtonElement;
let labelElement: HTMLLabelElement;
let inputElement: HTMLInputElement;

// This initialization is async() because it needs to wait for ngModel to set the initial value.
beforeEach(async(() => {
Expand All @@ -374,9 +375,17 @@ describe('MdSlideToggle', () => {

buttonElement = fixture.debugElement.query(By.css('button')).nativeElement;
labelElement = fixture.debugElement.query(By.css('label')).nativeElement;
inputElement = fixture.debugElement.query(By.css('input')).nativeElement;
}));

it('should prevent the form from submit when being required', async(() => {
it('should prevent the form from submit when being required', () => {

if ('reportValidity' in inputElement === false) {
// If the browser does not report the validity then the tests will break.
// e.g Safari 8 on Mobile.
return;
}

testComponent.isRequired = true;

fixture.detectChanges();
Expand All @@ -393,7 +402,7 @@ describe('MdSlideToggle', () => {
fixture.detectChanges();

expect(testComponent.isSubmitted).toBe(true);
}));
});

});

Expand Down

0 comments on commit 823307e

Please sign in to comment.