11import { CollectionViewer , DataSource } from '@angular/cdk/collections' ;
22import { Component , Type , ViewChild } from '@angular/core' ;
3- import { ComponentFixture , fakeAsync , flushMicrotasks , TestBed } from '@angular/core/testing' ;
3+ import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ;
44import { BehaviorSubject , combineLatest } from 'rxjs' ;
55import { map } from 'rxjs/operators' ;
66import { CdkTable , CdkTableModule } from '@angular/cdk/table' ;
@@ -48,10 +48,10 @@ describe('CdkTableScrollContainer', () => {
4848 dataRows = getRows ( tableElement ) ;
4949 } ) ;
5050
51- it ( 'sets scrollbar track margin for sticky headers' , fakeAsync ( ( ) => {
51+ it ( 'sets scrollbar track margin for sticky headers' , waitForAsync ( async ( ) => {
5252 component . stickyHeaders = [ 'header-1' , 'header-3' ] ;
5353 fixture . detectChanges ( ) ;
54- flushMicrotasks ( ) ;
54+ await new Promise ( r => setTimeout ( r ) ) ;
5555
5656 if ( platform . FIREFOX ) {
5757 // ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -66,18 +66,18 @@ describe('CdkTableScrollContainer', () => {
6666
6767 component . stickyHeaders = [ ] ;
6868 fixture . detectChanges ( ) ;
69- flushMicrotasks ( ) ;
69+ await new Promise ( r => setTimeout ( r ) ) ;
7070
7171 expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
7272 expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
7373 expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
7474 expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
7575 } ) ) ;
7676
77- it ( 'sets scrollbar track margin for sticky footers' , fakeAsync ( ( ) => {
77+ it ( 'sets scrollbar track margin for sticky footers' , waitForAsync ( async ( ) => {
7878 component . stickyFooters = [ 'footer-1' , 'footer-3' ] ;
7979 fixture . detectChanges ( ) ;
80- flushMicrotasks ( ) ;
80+ await new Promise ( r => setTimeout ( r ) ) ;
8181
8282 if ( platform . FIREFOX ) {
8383 // ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -92,18 +92,18 @@ describe('CdkTableScrollContainer', () => {
9292
9393 component . stickyFooters = [ ] ;
9494 fixture . detectChanges ( ) ;
95- flushMicrotasks ( ) ;
95+ await new Promise ( r => setTimeout ( r ) ) ;
9696
9797 expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
9898 expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
9999 expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
100100 expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
101101 } ) ) ;
102102
103- it ( 'sets scrollbar track margin for sticky start columns' , fakeAsync ( ( ) => {
103+ it ( 'sets scrollbar track margin for sticky start columns' , waitForAsync ( async ( ) => {
104104 component . stickyStartColumns = [ 'column-1' , 'column-3' ] ;
105105 fixture . detectChanges ( ) ;
106- flushMicrotasks ( ) ;
106+ await new Promise ( r => setTimeout ( r ) ) ;
107107
108108 if ( platform . FIREFOX ) {
109109 // ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -120,18 +120,18 @@ describe('CdkTableScrollContainer', () => {
120120
121121 component . stickyStartColumns = [ ] ;
122122 fixture . detectChanges ( ) ;
123- flushMicrotasks ( ) ;
123+ await new Promise ( r => setTimeout ( r ) ) ;
124124
125125 expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
126126 expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
127127 expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
128128 expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
129129 } ) ) ;
130130
131- it ( 'sets scrollbar track margin for sticky end columns' , fakeAsync ( ( ) => {
131+ it ( 'sets scrollbar track margin for sticky end columns' , waitForAsync ( async ( ) => {
132132 component . stickyEndColumns = [ 'column-4' , 'column-6' ] ;
133133 fixture . detectChanges ( ) ;
134- flushMicrotasks ( ) ;
134+ await new Promise ( r => setTimeout ( r ) ) ;
135135
136136 if ( platform . FIREFOX ) {
137137 // ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -148,21 +148,21 @@ describe('CdkTableScrollContainer', () => {
148148
149149 component . stickyEndColumns = [ ] ;
150150 fixture . detectChanges ( ) ;
151- flushMicrotasks ( ) ;
151+ await new Promise ( r => setTimeout ( r ) ) ;
152152
153153 expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
154154 expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
155155 expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
156156 expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
157157 } ) ) ;
158158
159- it ( 'sets scrollbar track margin for a combination of sticky rows and columns' , fakeAsync ( ( ) => {
159+ it ( 'sets scrollbar track margin for a combination of sticky rows and columns' , waitForAsync ( async ( ) => {
160160 component . stickyHeaders = [ 'header-1' ] ;
161161 component . stickyFooters = [ 'footer-3' ] ;
162162 component . stickyStartColumns = [ 'column-1' ] ;
163163 component . stickyEndColumns = [ 'column-6' ] ;
164164 fixture . detectChanges ( ) ;
165- flushMicrotasks ( ) ;
165+ await new Promise ( r => setTimeout ( r ) ) ;
166166
167167 if ( platform . FIREFOX ) {
168168 // ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -184,7 +184,7 @@ describe('CdkTableScrollContainer', () => {
184184 component . stickyStartColumns = [ ] ;
185185 component . stickyEndColumns = [ ] ;
186186 fixture . detectChanges ( ) ;
187- flushMicrotasks ( ) ;
187+ await new Promise ( r => setTimeout ( r ) ) ;
188188
189189 expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
190190 expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
0 commit comments