1- import { TestBed , fakeAsync , ComponentFixture , tick } from '@angular/core/testing' ;
1+ import { TestBed , ComponentFixture } from '@angular/core/testing' ;
22import { Component , ViewChild , ElementRef , ChangeDetectionStrategy } from '@angular/core' ;
33import { CdkScrollable , ScrollDispatcher , ScrollingModule } from './public-api' ;
44import { dispatchFakeEvent } from '../testing/private' ;
@@ -31,7 +31,7 @@ describe('ScrollDispatcher', () => {
3131 expect ( scroll . scrollContainers . has ( componentScrollable ) ) . toBe ( false ) ;
3232 } ) ;
3333
34- it ( 'should notify through the directive and service that a scroll event occurred' , fakeAsync ( ( ) => {
34+ it ( 'should notify through the directive and service that a scroll event occurred' , async ( ) => {
3535 // Listen for notifications from scroll directive
3636 const scrollable = fixture . componentInstance . scrollable ;
3737 const directiveSpy = jasmine . createSpy ( 'directive scroll callback' ) ;
@@ -55,9 +55,9 @@ describe('ScrollDispatcher', () => {
5555 expect ( serviceSpy ) . not . toHaveBeenCalled ( ) ;
5656
5757 // After the throttle time, the notification should be sent.
58- tick ( throttleTime ) ;
58+ await new Promise ( resolve => setTimeout ( resolve , throttleTime + 10 ) ) ;
5959 expect ( serviceSpy ) . toHaveBeenCalled ( ) ;
60- } ) ) ;
60+ } ) ;
6161
6262 it ( 'should be able to unsubscribe from the global scrollable' , ( ) => {
6363 const spy = jasmine . createSpy ( 'global scroll callback' ) ;
0 commit comments