Skip to content

Commit c75cc6a

Browse files
committed
Safari 8 does not report input validity in forms, so the tests fail for it..
1 parent 283e88e commit c75cc6a

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
@@ -363,6 +363,7 @@ describe('MdSlideToggle', () => {
363363
let testComponent: SlideToggleFormsTestApp;
364364
let buttonElement: HTMLButtonElement;
365365
let labelElement: HTMLLabelElement;
366+
let inputElement: HTMLInputElement;
366367

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

375376
buttonElement = fixture.debugElement.query(By.css('button')).nativeElement;
376377
labelElement = fixture.debugElement.query(By.css('label')).nativeElement;
378+
inputElement = fixture.debugElement.query(By.css('input')).nativeElement;
377379
}));
378380

379-
it('should prevent the form from submit when being required', async(() => {
381+
it('should prevent the form from submit when being required', () => {
382+
383+
if ('reportValidity' in inputElement === false) {
384+
// If the browser does not report the validity then the tests will break.
385+
// e.g Safari 8 on Mobile.
386+
return;
387+
}
388+
380389
testComponent.isRequired = true;
381390

382391
fixture.detectChanges();
@@ -393,7 +402,7 @@ describe('MdSlideToggle', () => {
393402
fixture.detectChanges();
394403

395404
expect(testComponent.isSubmitted).toBe(true);
396-
}));
405+
});
397406

398407
});
399408

0 commit comments

Comments
 (0)