1
1
import { CollectionViewer , DataSource } from '@angular/cdk/collections' ;
2
2
import { 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' ;
4
4
import { BehaviorSubject , combineLatest } from 'rxjs' ;
5
5
import { map } from 'rxjs/operators' ;
6
6
import { CdkTable , CdkTableModule } from '@angular/cdk/table' ;
@@ -48,10 +48,10 @@ describe('CdkTableScrollContainer', () => {
48
48
dataRows = getRows ( tableElement ) ;
49
49
} ) ;
50
50
51
- it ( 'sets scrollbar track margin for sticky headers' , fakeAsync ( ( ) => {
51
+ it ( 'sets scrollbar track margin for sticky headers' , waitForAsync ( async ( ) => {
52
52
component . stickyHeaders = [ 'header-1' , 'header-3' ] ;
53
53
fixture . detectChanges ( ) ;
54
- flushMicrotasks ( ) ;
54
+ await new Promise ( r => setTimeout ( r ) ) ;
55
55
56
56
if ( platform . FIREFOX ) {
57
57
// ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -66,18 +66,18 @@ describe('CdkTableScrollContainer', () => {
66
66
67
67
component . stickyHeaders = [ ] ;
68
68
fixture . detectChanges ( ) ;
69
- flushMicrotasks ( ) ;
69
+ await new Promise ( r => setTimeout ( r ) ) ;
70
70
71
71
expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
72
72
expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
73
73
expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
74
74
expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
75
75
} ) ) ;
76
76
77
- it ( 'sets scrollbar track margin for sticky footers' , fakeAsync ( ( ) => {
77
+ it ( 'sets scrollbar track margin for sticky footers' , waitForAsync ( async ( ) => {
78
78
component . stickyFooters = [ 'footer-1' , 'footer-3' ] ;
79
79
fixture . detectChanges ( ) ;
80
- flushMicrotasks ( ) ;
80
+ await new Promise ( r => setTimeout ( r ) ) ;
81
81
82
82
if ( platform . FIREFOX ) {
83
83
// ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -92,18 +92,18 @@ describe('CdkTableScrollContainer', () => {
92
92
93
93
component . stickyFooters = [ ] ;
94
94
fixture . detectChanges ( ) ;
95
- flushMicrotasks ( ) ;
95
+ await new Promise ( r => setTimeout ( r ) ) ;
96
96
97
97
expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
98
98
expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
99
99
expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
100
100
expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
101
101
} ) ) ;
102
102
103
- it ( 'sets scrollbar track margin for sticky start columns' , fakeAsync ( ( ) => {
103
+ it ( 'sets scrollbar track margin for sticky start columns' , waitForAsync ( async ( ) => {
104
104
component . stickyStartColumns = [ 'column-1' , 'column-3' ] ;
105
105
fixture . detectChanges ( ) ;
106
- flushMicrotasks ( ) ;
106
+ await new Promise ( r => setTimeout ( r ) ) ;
107
107
108
108
if ( platform . FIREFOX ) {
109
109
// ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -120,18 +120,18 @@ describe('CdkTableScrollContainer', () => {
120
120
121
121
component . stickyStartColumns = [ ] ;
122
122
fixture . detectChanges ( ) ;
123
- flushMicrotasks ( ) ;
123
+ await new Promise ( r => setTimeout ( r ) ) ;
124
124
125
125
expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
126
126
expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
127
127
expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
128
128
expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
129
129
} ) ) ;
130
130
131
- it ( 'sets scrollbar track margin for sticky end columns' , fakeAsync ( ( ) => {
131
+ it ( 'sets scrollbar track margin for sticky end columns' , waitForAsync ( async ( ) => {
132
132
component . stickyEndColumns = [ 'column-4' , 'column-6' ] ;
133
133
fixture . detectChanges ( ) ;
134
- flushMicrotasks ( ) ;
134
+ await new Promise ( r => setTimeout ( r ) ) ;
135
135
136
136
if ( platform . FIREFOX ) {
137
137
// ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -148,21 +148,21 @@ describe('CdkTableScrollContainer', () => {
148
148
149
149
component . stickyEndColumns = [ ] ;
150
150
fixture . detectChanges ( ) ;
151
- flushMicrotasks ( ) ;
151
+ await new Promise ( r => setTimeout ( r ) ) ;
152
152
153
153
expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
154
154
expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
155
155
expect ( scrollerStyle . getPropertyValue ( 'margin-bottom' ) ) . toBe ( '0px' ) ;
156
156
expect ( scrollerStyle . getPropertyValue ( 'margin-left' ) ) . toBe ( '0px' ) ;
157
157
} ) ) ;
158
158
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 ( ) => {
160
160
component . stickyHeaders = [ 'header-1' ] ;
161
161
component . stickyFooters = [ 'footer-3' ] ;
162
162
component . stickyStartColumns = [ 'column-1' ] ;
163
163
component . stickyEndColumns = [ 'column-6' ] ;
164
164
fixture . detectChanges ( ) ;
165
- flushMicrotasks ( ) ;
165
+ await new Promise ( r => setTimeout ( r ) ) ;
166
166
167
167
if ( platform . FIREFOX ) {
168
168
// ::-webkit-scrollbar-track is not recognized by Firefox.
@@ -184,7 +184,7 @@ describe('CdkTableScrollContainer', () => {
184
184
component . stickyStartColumns = [ ] ;
185
185
component . stickyEndColumns = [ ] ;
186
186
fixture . detectChanges ( ) ;
187
- flushMicrotasks ( ) ;
187
+ await new Promise ( r => setTimeout ( r ) ) ;
188
188
189
189
expect ( scrollerStyle . getPropertyValue ( 'margin-top' ) ) . toBe ( '0px' ) ;
190
190
expect ( scrollerStyle . getPropertyValue ( 'margin-right' ) ) . toBe ( '0px' ) ;
0 commit comments