@@ -4,17 +4,9 @@ import {
4
4
dispatchFakeEvent ,
5
5
dispatchKeyboardEvent ,
6
6
dispatchMouseEvent ,
7
- MockNgZone ,
8
7
} from '@angular/cdk/testing/private' ;
9
- import { Component , NgZone } from '@angular/core' ;
10
- import {
11
- fakeAsync ,
12
- waitForAsync ,
13
- ComponentFixture ,
14
- inject ,
15
- TestBed ,
16
- tick ,
17
- } from '@angular/core/testing' ;
8
+ import { Component } from '@angular/core' ;
9
+ import { waitForAsync , ComponentFixture , inject , TestBed } from '@angular/core/testing' ;
18
10
import { DateAdapter , MatNativeDateModule } from '@angular/material/core' ;
19
11
import { DEC , FEB , JAN , JUL , NOV } from '../testing' ;
20
12
import { By } from '@angular/platform-browser' ;
@@ -23,16 +15,10 @@ import {MatDatepickerIntl} from './datepicker-intl';
23
15
import { MatDatepickerModule } from './datepicker-module' ;
24
16
25
17
describe ( 'MatCalendar' , ( ) => {
26
- let zone : MockNgZone ;
27
-
28
18
beforeEach ( waitForAsync ( ( ) => {
29
19
TestBed . configureTestingModule ( {
30
20
imports : [ MatNativeDateModule , MatDatepickerModule ] ,
31
- providers : [
32
- MatDatepickerIntl ,
33
- { provide : NgZone , useFactory : ( ) => ( zone = new MockNgZone ( ) ) } ,
34
- { provide : Directionality , useFactory : ( ) => ( { value : 'ltr' } ) } ,
35
- ] ,
21
+ providers : [ MatDatepickerIntl , { provide : Directionality , useFactory : ( ) => ( { value : 'ltr' } ) } ] ,
36
22
declarations : [
37
23
// Test components.
38
24
StandardCalendar ,
@@ -183,19 +169,19 @@ describe('MatCalendar', () => {
183
169
expect ( calendarBodyEl . getAttribute ( 'tabindex' ) ) . toBe ( '-1' ) ;
184
170
} ) ;
185
171
186
- it ( 'should not move focus to the active cell on init' , ( ) => {
172
+ it ( 'should not move focus to the active cell on init' , waitForAsync ( async ( ) => {
187
173
const activeCell = calendarBodyEl . querySelector (
188
174
'.mat-calendar-body-active' ,
189
175
) ! as HTMLElement ;
190
176
191
177
spyOn ( activeCell , 'focus' ) . and . callThrough ( ) ;
192
178
fixture . detectChanges ( ) ;
193
- zone . simulateZoneExit ( ) ;
179
+ await new Promise ( resolve => setTimeout ( resolve ) ) ;
194
180
195
181
expect ( activeCell . focus ) . not . toHaveBeenCalled ( ) ;
196
- } ) ;
182
+ } ) ) ;
197
183
198
- it ( 'should move focus to the active cell when the view changes' , fakeAsync ( ( ) => {
184
+ it ( 'should move focus to the active cell when the view changes' , waitForAsync ( async ( ) => {
199
185
calendarInstance . currentView = 'multi-year' ;
200
186
fixture . detectChanges ( ) ;
201
187
@@ -204,8 +190,7 @@ describe('MatCalendar', () => {
204
190
) ! as HTMLElement ;
205
191
spyOn ( activeCell , 'focus' ) . and . callThrough ( ) ;
206
192
207
- zone . simulateZoneExit ( ) ;
208
- tick ( ) ;
193
+ await new Promise ( resolve => setTimeout ( resolve ) ) ;
209
194
210
195
expect ( activeCell . focus ) . toHaveBeenCalled ( ) ;
211
196
} ) ) ;
0 commit comments