@@ -2,7 +2,7 @@ import {TAB} from '../../keycodes';
2
2
import { Platform } from '../../platform' ;
3
3
import { DOCUMENT } from '@angular/common' ;
4
4
import { Component , ViewChild } from '@angular/core' ;
5
- import { ComponentFixture , TestBed , fakeAsync , flush , inject , tick } from '@angular/core/testing' ;
5
+ import { ComponentFixture , TestBed , fakeAsync , flush , tick } from '@angular/core/testing' ;
6
6
import { By } from '@angular/platform-browser' ;
7
7
import {
8
8
createMouseEvent ,
@@ -60,19 +60,17 @@ describe('FocusMonitor', () => {
60
60
} ,
61
61
] ,
62
62
} ) ;
63
- } ) ;
64
63
65
- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
66
64
fixture = TestBed . createComponent ( PlainButton ) ;
67
65
fixture . detectChanges ( ) ;
68
66
69
67
buttonElement = fixture . debugElement . query ( By . css ( 'button' ) ) ! . nativeElement ;
70
- focusMonitor = fm ;
68
+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
71
69
72
70
changeHandler = jasmine . createSpy ( 'focus origin change handler' ) ;
73
71
focusMonitor . monitor ( buttonElement ) . subscribe ( changeHandler ) ;
74
72
patchElementFocus ( buttonElement ) ;
75
- } ) ) ;
73
+ } ) ;
76
74
77
75
it ( 'manually registered element should receive focus classes' , fakeAsync ( ( ) => {
78
76
buttonElement . focus ( ) ;
@@ -479,19 +477,17 @@ describe('FocusMonitor with "eventual" detection', () => {
479
477
} ,
480
478
] ,
481
479
} ) ;
482
- } ) ;
483
480
484
- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
485
481
fixture = TestBed . createComponent ( PlainButton ) ;
486
482
fixture . detectChanges ( ) ;
487
483
488
484
buttonElement = fixture . debugElement . query ( By . css ( 'button' ) ) ! . nativeElement ;
489
- focusMonitor = fm ;
485
+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
490
486
491
487
changeHandler = jasmine . createSpy ( 'focus origin change handler' ) ;
492
488
focusMonitor . monitor ( buttonElement ) . subscribe ( changeHandler ) ;
493
489
patchElementFocus ( buttonElement ) ;
494
- } ) ) ;
490
+ } ) ;
495
491
496
492
it ( 'should not clear the focus origin, even after a few seconds' , fakeAsync ( ( ) => {
497
493
dispatchKeyboardEvent ( document , 'keydown' , TAB ) ;
@@ -712,8 +708,8 @@ describe('cdkMonitorFocus', () => {
712
708
let childElement : HTMLElement ;
713
709
let focusMonitor : FocusMonitor ;
714
710
715
- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
716
- focusMonitor = fm ;
711
+ beforeEach ( ( ) => {
712
+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
717
713
fixture = TestBed . createComponent (
718
714
ComplexComponentWithMonitorSubtreeFocusAndMonitorElementFocus ,
719
715
) ;
@@ -724,7 +720,7 @@ describe('cdkMonitorFocus', () => {
724
720
725
721
patchElementFocus ( parentElement ) ;
726
722
patchElementFocus ( childElement ) ;
727
- } ) ) ;
723
+ } ) ;
728
724
729
725
it ( 'should add keyboard focus classes on both elements when child is focused via keyboard' , fakeAsync ( ( ) => {
730
726
focusMonitor . focusVia ( childElement , 'keyboard' ) ;
@@ -828,15 +824,12 @@ describe('FocusMonitor observable stream', () => {
828
824
imports : [ A11yModule , PlainButton ] ,
829
825
providers : [ { provide : Platform , useValue : fakePlatform } ] ,
830
826
} ) ;
831
- } ) ;
832
-
833
- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
834
827
fixture = TestBed . createComponent ( PlainButton ) ;
835
- focusMonitor = fm ;
828
+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
836
829
fixture . detectChanges ( ) ;
837
830
buttonElement = fixture . debugElement . nativeElement . querySelector ( 'button' ) ;
838
831
patchElementFocus ( buttonElement ) ;
839
- } ) ) ;
832
+ } ) ;
840
833
841
834
it ( 'should not emit on the server' , fakeAsync ( ( ) => {
842
835
fakePlatform . isBrowser = false ;
@@ -865,16 +858,13 @@ describe('FocusMonitor input label detection', () => {
865
858
TestBed . configureTestingModule ( {
866
859
imports : [ A11yModule , CheckboxWithLabel ] ,
867
860
} ) ;
868
- } ) ;
869
-
870
- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
871
861
fixture = TestBed . createComponent ( CheckboxWithLabel ) ;
872
- focusMonitor = fm ;
862
+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
873
863
fixture . detectChanges ( ) ;
874
864
inputElement = fixture . nativeElement . querySelector ( 'input' ) ;
875
865
labelElement = fixture . nativeElement . querySelector ( 'label' ) ;
876
866
patchElementFocus ( inputElement ) ;
877
- } ) ) ;
867
+ } ) ;
878
868
879
869
it ( 'should detect label click focus as `mouse`' , fakeAsync ( ( ) => {
880
870
const spy = jasmine . createSpy ( 'monitor spy' ) ;
0 commit comments