6
6
ViewChild ,
7
7
ViewContainerRef ,
8
8
ViewEncapsulation ,
9
- inject as inject_1 ,
9
+ inject ,
10
10
} from '@angular/core' ;
11
11
import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ;
12
12
import { By } from '@angular/platform-browser' ;
@@ -217,16 +217,13 @@ describe('FocusTrap', () => {
217
217
fixture . componentInstance . showTrappedRegion = true ;
218
218
fixture . changeDetectorRef . markForCheck ( ) ;
219
219
fixture . detectChanges ( ) ;
220
+ expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
220
221
221
- fixture . whenStable ( ) . then ( ( ) => {
222
- expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
223
-
224
- fixture . componentInstance . showTrappedRegion = false ;
225
- fixture . changeDetectorRef . markForCheck ( ) ;
226
- fixture . detectChanges ( ) ;
222
+ fixture . componentInstance . showTrappedRegion = false ;
223
+ fixture . changeDetectorRef . markForCheck ( ) ;
224
+ fixture . detectChanges ( ) ;
227
225
228
- expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
229
- } ) ;
226
+ expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
230
227
} ) ) ;
231
228
232
229
it ( 'should capture focus if auto capture is enabled later on' , waitForAsync ( ( ) => {
@@ -243,16 +240,13 @@ describe('FocusTrap', () => {
243
240
fixture . componentInstance . autoCaptureEnabled = true ;
244
241
fixture . changeDetectorRef . markForCheck ( ) ;
245
242
fixture . detectChanges ( ) ;
243
+ expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
246
244
247
- fixture . whenStable ( ) . then ( ( ) => {
248
- expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
249
-
250
- fixture . componentInstance . showTrappedRegion = false ;
251
- fixture . changeDetectorRef . markForCheck ( ) ;
252
- fixture . detectChanges ( ) ;
245
+ fixture . componentInstance . showTrappedRegion = false ;
246
+ fixture . changeDetectorRef . markForCheck ( ) ;
247
+ fixture . detectChanges ( ) ;
253
248
254
- expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
255
- } ) ;
249
+ expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
256
250
} ) ) ;
257
251
258
252
it ( 'should automatically capture and return focus on init / destroy inside the shadow DOM' , waitForAsync ( ( ) => {
@@ -270,16 +264,13 @@ describe('FocusTrap', () => {
270
264
fixture . componentInstance . showTrappedRegion = true ;
271
265
fixture . changeDetectorRef . markForCheck ( ) ;
272
266
fixture . detectChanges ( ) ;
267
+ expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
273
268
274
- fixture . whenStable ( ) . then ( ( ) => {
275
- expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
276
-
277
- fixture . componentInstance . showTrappedRegion = false ;
278
- fixture . changeDetectorRef . markForCheck ( ) ;
279
- fixture . detectChanges ( ) ;
269
+ fixture . componentInstance . showTrappedRegion = false ;
270
+ fixture . changeDetectorRef . markForCheck ( ) ;
271
+ fixture . detectChanges ( ) ;
280
272
281
- expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
282
- } ) ;
273
+ expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
283
274
} ) ) ;
284
275
285
276
it ( 'should capture focus if auto capture is enabled later on inside the shadow DOM' , waitForAsync ( ( ) => {
@@ -300,16 +291,13 @@ describe('FocusTrap', () => {
300
291
fixture . componentInstance . autoCaptureEnabled = true ;
301
292
fixture . changeDetectorRef . markForCheck ( ) ;
302
293
fixture . detectChanges ( ) ;
294
+ expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
303
295
304
- fixture . whenStable ( ) . then ( ( ) => {
305
- expect ( getActiveElement ( ) . id ) . toBe ( 'auto-capture-target' ) ;
306
-
307
- fixture . componentInstance . showTrappedRegion = false ;
308
- fixture . changeDetectorRef . markForCheck ( ) ;
309
- fixture . detectChanges ( ) ;
296
+ fixture . componentInstance . showTrappedRegion = false ;
297
+ fixture . changeDetectorRef . markForCheck ( ) ;
298
+ fixture . detectChanges ( ) ;
310
299
311
- expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
312
- } ) ;
300
+ expect ( getActiveElement ( ) ) . toBe ( buttonOutsideTrappedRegion ) ;
313
301
} ) ) ;
314
302
} ) ;
315
303
@@ -473,7 +461,7 @@ class FocusTrapWithoutFocusableElements {
473
461
imports : [ A11yModule , PortalModule ] ,
474
462
} )
475
463
class FocusTrapInsidePortal {
476
- viewContainerRef = inject_1 ( ViewContainerRef ) ;
464
+ viewContainerRef = inject ( ViewContainerRef ) ;
477
465
478
466
@ViewChild ( 'template' ) template : TemplateRef < any > ;
479
467
@ViewChild ( CdkPortalOutlet ) portalOutlet : CdkPortalOutlet ;
0 commit comments