3
3
waitForAsync ,
4
4
ComponentFixture ,
5
5
fakeAsync ,
6
+ flush ,
6
7
flushMicrotasks ,
7
8
TestBed ,
8
9
tick ,
@@ -214,6 +215,7 @@ describe('MDC-based MatTable', () => {
214
215
215
216
const stuckCellElement = fixture . nativeElement . querySelector ( 'table th' ) ! ;
216
217
expect ( stuckCellElement . classList ) . toContain ( 'mat-mdc-table-sticky' ) ;
218
+ flush ( ) ;
217
219
} ) ) ;
218
220
219
221
// Note: needs to be fakeAsync so it catches the error.
@@ -242,6 +244,7 @@ describe('MDC-based MatTable', () => {
242
244
beforeEach ( fakeAsync ( ( ) => {
243
245
fixture = TestBed . createComponent ( ArrayDataSourceMatTableApp ) ;
244
246
fixture . detectChanges ( ) ;
247
+ flush ( ) ;
245
248
246
249
tableElement = fixture . nativeElement . querySelector ( 'table' ) ;
247
250
component = fixture . componentInstance ;
@@ -322,6 +325,7 @@ describe('MDC-based MatTable', () => {
322
325
[ 'a_1' , 'b_1' , 'c_1' ] ,
323
326
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
324
327
] ) ;
328
+ flush ( ) ;
325
329
326
330
flushMicrotasks ( ) ; // Resolve promise that updates paginator's length
327
331
expect ( dataSource . paginator ! . length ) . toBe ( 1 ) ;
@@ -336,6 +340,7 @@ describe('MDC-based MatTable', () => {
336
340
[ 'a_2' , 'b_2' , 'c_2' ] ,
337
341
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
338
342
] ) ;
343
+ flush ( ) ;
339
344
340
345
// Change filter to empty string, should match all rows
341
346
dataSource . filter = '' ;
@@ -351,6 +356,7 @@ describe('MDC-based MatTable', () => {
351
356
[ 'a_3' , 'b_3' , 'c_3' ] ,
352
357
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
353
358
] ) ;
359
+ flush ( ) ;
354
360
355
361
// Change filter function and filter, should match to rows with zebra.
356
362
dataSource . filterPredicate = ( data , filter ) => {
@@ -378,6 +384,7 @@ describe('MDC-based MatTable', () => {
378
384
[ 'a_2' , 'b_2' , 'c_2' ] ,
379
385
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
380
386
] ) ;
387
+ flush ( ) ;
381
388
382
389
// Change the filter to a falsy value that might come in from the view.
383
390
dataSource . filter = 0 as any ;
@@ -386,6 +393,7 @@ describe('MDC-based MatTable', () => {
386
393
[ 'Column A' , 'Column B' , 'Column C' ] ,
387
394
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
388
395
] ) ;
396
+ flush ( ) ;
389
397
} ) ) ;
390
398
391
399
it ( 'should not match concatenated words' , fakeAsync ( ( ) => {
@@ -398,6 +406,7 @@ describe('MDC-based MatTable', () => {
398
406
[ 'Column A' , 'Column B' , 'Column C' ] ,
399
407
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
400
408
] ) ;
409
+ flush ( ) ;
401
410
} ) ) ;
402
411
403
412
it ( 'should be able to sort the table contents' , ( ) => {
@@ -547,6 +556,7 @@ describe('MDC-based MatTable', () => {
547
556
[ 'a_5' , 'b_5' , 'c_5' ] ,
548
557
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
549
558
] ) ;
559
+ flush ( ) ;
550
560
551
561
// Navigate to the next page
552
562
component . paginator . nextPage ( ) ;
@@ -560,6 +570,7 @@ describe('MDC-based MatTable', () => {
560
570
[ 'a_10' , 'b_10' , 'c_10' ] ,
561
571
[ 'Footer A' , 'Footer B' , 'Footer C' ] ,
562
572
] ) ;
573
+ flush ( ) ;
563
574
} ) ) ;
564
575
565
576
it ( 'should sort strings with numbers larger than MAX_SAFE_INTEGER correctly' , ( ) => {
0 commit comments