Skip to content

Commit a265226

Browse files
committed
test: update failing test
use tick() to simulate deboucetime
1 parent 164203b commit a265226

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

projects/mat-advanced-table/src/lib/mat-advanced-table.component.spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { SimpleChange, Component } from "@angular/core";
2-
import { async, ComponentFixture, TestBed } from "@angular/core/testing";
2+
import {
3+
async,
4+
ComponentFixture,
5+
TestBed,
6+
tick,
7+
fakeAsync,
8+
flush,
9+
} from "@angular/core/testing";
310
import {
411
MatPaginator,
512
MatSortHeader,
@@ -172,15 +179,16 @@ describe("MatAdvancedTableComponent", () => {
172179
});
173180
});
174181
});
175-
it("should filter data using search input", () => {
182+
it("should filter data using search input", fakeAsync(() => {
176183
setupData();
177184
component.searchControl.setValue(21);
178-
component.cdr.detectChanges();
185+
tick(component.options.searchDebouce);
186+
fixture.detectChanges();
179187
const rows: HTMLTableRowElement[] = Array.from(
180188
fixture.nativeElement.querySelectorAll("table tbody tr")
181189
);
182190
expect(rows.length).toEqual(1);
183-
});
191+
}));
184192
});
185193
describe("creating the component with custom options", () => {
186194
beforeEach(() => {

0 commit comments

Comments
 (0)