Skip to content

Commit f95780f

Browse files
committed
Try fixing timing issues by splitting tests which have more than 1 setTimeout
Try fixing timing issues by splitting tests which have more than 1 setTimeout
1 parent 39ac945 commit f95780f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

tests/unit/ighierarchicalgrid/hierarchicalgrid.spec.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function main() {
3636
});
3737
}));
3838

39-
it('should reflect changes when a record is added/removed from the data',
39+
it('should reflect changes when a record is removed from the data',
4040
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
4141
var template = '<div><ig-hierarchical-grid [(widgetId)]="gridID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-hierarchical-grid></div>';
4242
tcb.overrideTemplate(TestComponent, template)
@@ -51,18 +51,29 @@ export function main() {
5151
expect($(fixture.debugElement.nativeElement).find("#grid1 tr").length)
5252
.toBe(8);
5353
expect($(fixture.debugElement.nativeElement).find("#grid1 tr:first td[aria-describedby='grid1_FirstName']").text())
54-
.toBe("Andrew");
54+
.toBe("Andrew");
55+
async.done();
56+
}, 10);
57+
});
58+
}));
59+
60+
it('should reflect changes when a record is added from the data',
61+
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
62+
var template = '<div><ig-hierarchical-grid [(widgetId)]="gridID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-hierarchical-grid></div>';
63+
tcb.overrideTemplate(TestComponent, template)
64+
.createAsync(TestComponent)
65+
.then((fixture) => {
66+
fixture.detectChanges();
5567
//add item
5668
fixture.componentInstance.data.push({ EmployeeID: 200, LastName: "Snow", FirstName: "John", Title: "Vice President, Sales"});
5769
setTimeout(() => {
5870
fixture.detectChanges();
5971
expect($(fixture.debugElement.nativeElement).find("#grid1 tr").length)
60-
.toBe(9);
61-
expect($(fixture.debugElement.nativeElement).find("#grid1 tr:last td[aria-describedby='grid1_FirstName']").text())
62-
.toBe("John");
72+
.toBe(10);
73+
expect($(fixture.debugElement.nativeElement).find("#grid1 tr:last td[aria-describedby='grid1_FirstName']").text())
74+
.toBe("John");
6375
async.done();
64-
}, 10);
65-
}, 10);
76+
}, 10);
6677
});
6778
}));
6879

0 commit comments

Comments
 (0)