@@ -2,7 +2,7 @@ import {TAB} from '../../keycodes';
22import { Platform } from '../../platform' ;
33import { DOCUMENT } from '@angular/common' ;
44import { 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' ;
66import { By } from '@angular/platform-browser' ;
77import {
88 createMouseEvent ,
@@ -60,19 +60,17 @@ describe('FocusMonitor', () => {
6060 } ,
6161 ] ,
6262 } ) ;
63- } ) ;
6463
65- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
6664 fixture = TestBed . createComponent ( PlainButton ) ;
6765 fixture . detectChanges ( ) ;
6866
6967 buttonElement = fixture . debugElement . query ( By . css ( 'button' ) ) ! . nativeElement ;
70- focusMonitor = fm ;
68+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
7169
7270 changeHandler = jasmine . createSpy ( 'focus origin change handler' ) ;
7371 focusMonitor . monitor ( buttonElement ) . subscribe ( changeHandler ) ;
7472 patchElementFocus ( buttonElement ) ;
75- } ) ) ;
73+ } ) ;
7674
7775 it ( 'manually registered element should receive focus classes' , fakeAsync ( ( ) => {
7876 buttonElement . focus ( ) ;
@@ -479,19 +477,17 @@ describe('FocusMonitor with "eventual" detection', () => {
479477 } ,
480478 ] ,
481479 } ) ;
482- } ) ;
483480
484- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
485481 fixture = TestBed . createComponent ( PlainButton ) ;
486482 fixture . detectChanges ( ) ;
487483
488484 buttonElement = fixture . debugElement . query ( By . css ( 'button' ) ) ! . nativeElement ;
489- focusMonitor = fm ;
485+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
490486
491487 changeHandler = jasmine . createSpy ( 'focus origin change handler' ) ;
492488 focusMonitor . monitor ( buttonElement ) . subscribe ( changeHandler ) ;
493489 patchElementFocus ( buttonElement ) ;
494- } ) ) ;
490+ } ) ;
495491
496492 it ( 'should not clear the focus origin, even after a few seconds' , fakeAsync ( ( ) => {
497493 dispatchKeyboardEvent ( document , 'keydown' , TAB ) ;
@@ -712,8 +708,8 @@ describe('cdkMonitorFocus', () => {
712708 let childElement : HTMLElement ;
713709 let focusMonitor : FocusMonitor ;
714710
715- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
716- focusMonitor = fm ;
711+ beforeEach ( ( ) => {
712+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
717713 fixture = TestBed . createComponent (
718714 ComplexComponentWithMonitorSubtreeFocusAndMonitorElementFocus ,
719715 ) ;
@@ -724,7 +720,7 @@ describe('cdkMonitorFocus', () => {
724720
725721 patchElementFocus ( parentElement ) ;
726722 patchElementFocus ( childElement ) ;
727- } ) ) ;
723+ } ) ;
728724
729725 it ( 'should add keyboard focus classes on both elements when child is focused via keyboard' , fakeAsync ( ( ) => {
730726 focusMonitor . focusVia ( childElement , 'keyboard' ) ;
@@ -828,15 +824,12 @@ describe('FocusMonitor observable stream', () => {
828824 imports : [ A11yModule , PlainButton ] ,
829825 providers : [ { provide : Platform , useValue : fakePlatform } ] ,
830826 } ) ;
831- } ) ;
832-
833- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
834827 fixture = TestBed . createComponent ( PlainButton ) ;
835- focusMonitor = fm ;
828+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
836829 fixture . detectChanges ( ) ;
837830 buttonElement = fixture . debugElement . nativeElement . querySelector ( 'button' ) ;
838831 patchElementFocus ( buttonElement ) ;
839- } ) ) ;
832+ } ) ;
840833
841834 it ( 'should not emit on the server' , fakeAsync ( ( ) => {
842835 fakePlatform . isBrowser = false ;
@@ -865,16 +858,13 @@ describe('FocusMonitor input label detection', () => {
865858 TestBed . configureTestingModule ( {
866859 imports : [ A11yModule , CheckboxWithLabel ] ,
867860 } ) ;
868- } ) ;
869-
870- beforeEach ( inject ( [ FocusMonitor ] , ( fm : FocusMonitor ) => {
871861 fixture = TestBed . createComponent ( CheckboxWithLabel ) ;
872- focusMonitor = fm ;
862+ focusMonitor = TestBed . inject ( FocusMonitor ) ;
873863 fixture . detectChanges ( ) ;
874864 inputElement = fixture . nativeElement . querySelector ( 'input' ) ;
875865 labelElement = fixture . nativeElement . querySelector ( 'label' ) ;
876866 patchElementFocus ( inputElement ) ;
877- } ) ) ;
867+ } ) ;
878868
879869 it ( 'should detect label click focus as `mouse`' , fakeAsync ( ( ) => {
880870 const spy = jasmine . createSpy ( 'monitor spy' ) ;
0 commit comments