Skip to content

Commit 88fda14

Browse files
committed
mdc table tests
1 parent cd4bbae commit 88fda14

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/material-experimental/mdc-table/table.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
waitForAsync,
44
ComponentFixture,
55
fakeAsync,
6+
flush,
67
flushMicrotasks,
78
TestBed,
89
tick,
@@ -214,6 +215,7 @@ describe('MDC-based MatTable', () => {
214215

215216
const stuckCellElement = fixture.nativeElement.querySelector('table th')!;
216217
expect(stuckCellElement.classList).toContain('mat-mdc-table-sticky');
218+
flush();
217219
}));
218220

219221
// Note: needs to be fakeAsync so it catches the error.
@@ -242,6 +244,7 @@ describe('MDC-based MatTable', () => {
242244
beforeEach(fakeAsync(() => {
243245
fixture = TestBed.createComponent(ArrayDataSourceMatTableApp);
244246
fixture.detectChanges();
247+
flush();
245248

246249
tableElement = fixture.nativeElement.querySelector('table');
247250
component = fixture.componentInstance;
@@ -322,6 +325,7 @@ describe('MDC-based MatTable', () => {
322325
['a_1', 'b_1', 'c_1'],
323326
['Footer A', 'Footer B', 'Footer C'],
324327
]);
328+
flush();
325329

326330
flushMicrotasks(); // Resolve promise that updates paginator's length
327331
expect(dataSource.paginator!.length).toBe(1);
@@ -336,6 +340,7 @@ describe('MDC-based MatTable', () => {
336340
['a_2', 'b_2', 'c_2'],
337341
['Footer A', 'Footer B', 'Footer C'],
338342
]);
343+
flush();
339344

340345
// Change filter to empty string, should match all rows
341346
dataSource.filter = '';
@@ -351,6 +356,7 @@ describe('MDC-based MatTable', () => {
351356
['a_3', 'b_3', 'c_3'],
352357
['Footer A', 'Footer B', 'Footer C'],
353358
]);
359+
flush();
354360

355361
// Change filter function and filter, should match to rows with zebra.
356362
dataSource.filterPredicate = (data, filter) => {
@@ -378,6 +384,7 @@ describe('MDC-based MatTable', () => {
378384
['a_2', 'b_2', 'c_2'],
379385
['Footer A', 'Footer B', 'Footer C'],
380386
]);
387+
flush();
381388

382389
// Change the filter to a falsy value that might come in from the view.
383390
dataSource.filter = 0 as any;
@@ -386,6 +393,7 @@ describe('MDC-based MatTable', () => {
386393
['Column A', 'Column B', 'Column C'],
387394
['Footer A', 'Footer B', 'Footer C'],
388395
]);
396+
flush();
389397
}));
390398

391399
it('should not match concatenated words', fakeAsync(() => {
@@ -398,6 +406,7 @@ describe('MDC-based MatTable', () => {
398406
['Column A', 'Column B', 'Column C'],
399407
['Footer A', 'Footer B', 'Footer C'],
400408
]);
409+
flush();
401410
}));
402411

403412
it('should be able to sort the table contents', () => {
@@ -547,6 +556,7 @@ describe('MDC-based MatTable', () => {
547556
['a_5', 'b_5', 'c_5'],
548557
['Footer A', 'Footer B', 'Footer C'],
549558
]);
559+
flush();
550560

551561
// Navigate to the next page
552562
component.paginator.nextPage();
@@ -560,6 +570,7 @@ describe('MDC-based MatTable', () => {
560570
['a_10', 'b_10', 'c_10'],
561571
['Footer A', 'Footer B', 'Footer C'],
562572
]);
573+
flush();
563574
}));
564575

565576
it('should sort strings with numbers larger than MAX_SAFE_INTEGER correctly', () => {

0 commit comments

Comments
 (0)