Skip to content

Commit cd4bbae

Browse files
committed
fix additional tests
1 parent ea6ffa5 commit cd4bbae

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/material-experimental/column-resize/column-resize.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, Directive, ElementRef, ViewChild, ChangeDetectionStrategy} from '@angular/core';
2-
import {ComponentFixture, TestBed, fakeAsync, flushMicrotasks} from '@angular/core/testing';
2+
import {ComponentFixture, TestBed, fakeAsync, flush, flushMicrotasks} from '@angular/core/testing';
33
import {BidiModule} from '@angular/cdk/bidi';
44
import {DataSource} from '@angular/cdk/collections';
55
import {dispatchKeyboardEvent} from '../../cdk/testing/private';
@@ -367,6 +367,7 @@ describe('Material Popover Edit', () => {
367367
component = fixture.componentInstance;
368368
fixture.detectChanges();
369369
flushMicrotasks();
370+
flush();
370371
}));
371372

372373
it('shows resize handle overlays on header row hover and while a resize handle is in use', fakeAsync(() => {

src/material/table/table.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
waitForAsync,
55
ComponentFixture,
66
fakeAsync,
7+
flush,
78
flushMicrotasks,
89
TestBed,
910
tick,
@@ -203,6 +204,7 @@ describe('MatTable', () => {
203204
const fixture = TestBed.createComponent(StickyTableApp);
204205
fixture.detectChanges();
205206
flushMicrotasks();
207+
flush();
206208

207209
const stuckCellElement = fixture.nativeElement.querySelector('.mat-table th')!;
208210
expect(stuckCellElement.classList).toContain('mat-table-sticky');
@@ -227,6 +229,7 @@ describe('MatTable', () => {
227229
beforeEach(fakeAsync(() => {
228230
fixture = TestBed.createComponent(ArrayDataSourceMatTableApp);
229231
fixture.detectChanges();
232+
flush();
230233

231234
tableElement = fixture.nativeElement.querySelector('.mat-table');
232235
component = fixture.componentInstance;
@@ -300,13 +303,15 @@ describe('MatTable', () => {
300303
// Change filter to a_1, should match one row
301304
dataSource.filter = 'a_1';
302305
fixture.detectChanges();
306+
flush();
303307
expect(dataSource.filteredData.length).toBe(1);
304308
expect(dataSource.filteredData[0]).toBe(dataSource.data[0]);
305309
expectTableToMatchContent(tableElement, [
306310
['Column A', 'Column B', 'Column C'],
307311
['a_1', 'b_1', 'c_1'],
308312
['Footer A', 'Footer B', 'Footer C'],
309313
]);
314+
flush();
310315

311316
flushMicrotasks(); // Resolve promise that updates paginator's length
312317
expect(dataSource.paginator!.length).toBe(1);
@@ -321,6 +326,7 @@ describe('MatTable', () => {
321326
['a_2', 'b_2', 'c_2'],
322327
['Footer A', 'Footer B', 'Footer C'],
323328
]);
329+
flush();
324330

325331
// Change filter to empty string, should match all rows
326332
dataSource.filter = '';
@@ -336,6 +342,7 @@ describe('MatTable', () => {
336342
['a_3', 'b_3', 'c_3'],
337343
['Footer A', 'Footer B', 'Footer C'],
338344
]);
345+
flush();
339346

340347
// Change filter function and filter, should match to rows with zebra.
341348
dataSource.filterPredicate = (data, filter) => {
@@ -363,6 +370,7 @@ describe('MatTable', () => {
363370
['a_2', 'b_2', 'c_2'],
364371
['Footer A', 'Footer B', 'Footer C'],
365372
]);
373+
flush();
366374

367375
// Change the filter to a falsy value that might come in from the view.
368376
dataSource.filter = 0 as any;
@@ -371,13 +379,15 @@ describe('MatTable', () => {
371379
['Column A', 'Column B', 'Column C'],
372380
['Footer A', 'Footer B', 'Footer C'],
373381
]);
382+
flush();
374383
}));
375384

376385
it('should not match concatenated words', fakeAsync(() => {
377386
// Set the value to the last character of the first
378387
// column plus the first character of the second column.
379388
dataSource.filter = '1b';
380389
fixture.detectChanges();
390+
flush();
381391
expect(dataSource.filteredData.length).toBe(0);
382392
expectTableToMatchContent(tableElement, [
383393
['Column A', 'Column B', 'Column C'],
@@ -523,6 +533,7 @@ describe('MatTable', () => {
523533
}
524534
fixture.detectChanges();
525535
flushMicrotasks(); // Resolve promise that updates paginator's length
536+
flush();
526537
expectTableToMatchContent(tableElement, [
527538
['Column A', 'Column B', 'Column C'],
528539
['a_1', 'b_1', 'c_1'],
@@ -536,6 +547,7 @@ describe('MatTable', () => {
536547
// Navigate to the next page
537548
component.paginator.nextPage();
538549
fixture.detectChanges();
550+
flush();
539551
expectTableToMatchContent(tableElement, [
540552
['Column A', 'Column B', 'Column C'],
541553
['a_6', 'b_6', 'c_6'],

0 commit comments

Comments
 (0)