@@ -3,17 +3,21 @@ import {By} from '@angular/platform-browser';
33import { Component } from '@angular/core' ;
44import { FocusTrap } from './focus-trap' ;
55import { InteractivityChecker } from './interactivity-checker' ;
6+ import { MdPlatform } from '../platform/platform' ;
67
78
89describe ( 'FocusTrap' , ( ) => {
10+
911 describe ( 'with default element' , ( ) => {
12+
1013 let fixture : ComponentFixture < FocusTrapTestApp > ;
1114 let focusTrapInstance : FocusTrap ;
15+ let platform : MdPlatform = new MdPlatform ( ) ;
1216
1317 beforeEach ( async ( ( ) => {
1418 TestBed . configureTestingModule ( {
1519 declarations : [ FocusTrap , FocusTrapTestApp ] ,
16- providers : [ InteractivityChecker ]
20+ providers : [ InteractivityChecker , MdPlatform ]
1721 } ) ;
1822
1923 TestBed . compileComponents ( ) ;
@@ -38,8 +42,11 @@ describe('FocusTrap', () => {
3842 // focus event handler directly.
3943 focusTrapInstance . focusLastTabbableElement ( ) ;
4044
45+ // In iOS button elements are never tabbable, so the last element will be the input.
46+ let lastElement = platform . IOS ? 'input' : 'button' ;
47+
4148 expect ( document . activeElement . nodeName . toLowerCase ( ) )
42- . toBe ( 'button' , ' Expected button element to be focused' ) ;
49+ . toBe ( lastElement , ` Expected ${ lastElement } element to be focused` ) ;
4350 } ) ;
4451 } ) ;
4552
@@ -50,7 +57,7 @@ describe('FocusTrap', () => {
5057 beforeEach ( async ( ( ) => {
5158 TestBed . configureTestingModule ( {
5259 declarations : [ FocusTrap , FocusTrapTargetTestApp ] ,
53- providers : [ InteractivityChecker ]
60+ providers : [ InteractivityChecker , MdPlatform ]
5461 } ) ;
5562
5663 TestBed . compileComponents ( ) ;
0 commit comments