Skip to content

Commit 488cb1c

Browse files
committed
Safari 8 does not report input validity in forms, so the tests fail for it..
1 parent ef3481c commit 488cb1c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lib/slide-toggle/slide-toggle.spec.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ describe('MdSlideToggle', () => {
349349
let testComponent: SlideToggleFormsTestApp;
350350
let buttonElement: HTMLButtonElement;
351351
let labelElement: HTMLLabelElement;
352+
let inputElement: HTMLInputElement;
352353

353354
// This initialization is async() because it needs to wait for ngModel to set the initial value.
354355
beforeEach(async(() => {
@@ -360,9 +361,17 @@ describe('MdSlideToggle', () => {
360361

361362
buttonElement = fixture.debugElement.query(By.css('button')).nativeElement;
362363
labelElement = fixture.debugElement.query(By.css('label')).nativeElement;
364+
inputElement = fixture.debugElement.query(By.css('input')).nativeElement;
363365
}));
364366

365-
it('should prevent the form from submit when being required', async(() => {
367+
it('should prevent the form from submit when being required', () => {
368+
369+
if ('reportValidity' in inputElement === false) {
370+
// If the browser does not report the validity then the tests will break.
371+
// e.g Safari 8 on Mobile.
372+
return;
373+
}
374+
366375
testComponent.isRequired = true;
367376

368377
fixture.detectChanges();
@@ -379,7 +388,7 @@ describe('MdSlideToggle', () => {
379388
fixture.detectChanges();
380389

381390
expect(testComponent.isSubmitted).toBe(true);
382-
}));
391+
});
383392

384393
});
385394

0 commit comments

Comments
 (0)