Skip to content

Commit 93e37b5

Browse files
Add test for dxList with empty dataSource (T580247) (#652)
1 parent 6fd9c84 commit 93e37b5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/src/ui/list.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class TestContainerComponent {
3030
emptyItems = undefined;
3131
items = [1];
3232
complexItems = [{ text: 'Item 1' }];
33+
emptyDataSource = { items: [] };
3334
defaultTemplateItems = [{ text: 'test', disabled: false }];
3435
disabled = false;
3536
@ViewChildren(DxListComponent) innerWidgets: QueryList<DxListComponent>;
@@ -72,6 +73,33 @@ describe('DxList', () => {
7273
instance.option.calls.reset();
7374
}));
7475

76+
it('should react to collection change for empty dataSource', async(() => {
77+
TestBed.overrideComponent(TestContainerComponent, {
78+
set: {
79+
template: `
80+
<dx-list [dataSource]="emptyDataSource.items">
81+
<div *dxTemplate="let i of 'item'">
82+
{{i}}
83+
</div>
84+
</dx-list>
85+
`
86+
}
87+
});
88+
let fixture = TestBed.createComponent(TestContainerComponent);
89+
fixture.detectChanges();
90+
91+
let testComponent = fixture.componentInstance,
92+
instance = getWidget(fixture);
93+
94+
testComponent.emptyDataSource = { items: [] };
95+
fixture.detectChanges();
96+
97+
testComponent.emptyDataSource.items.push({ id: 1 });
98+
fixture.detectChanges();
99+
100+
expect(instance.option('items').length).toBe(1);
101+
}));
102+
75103
it('should not react if the same value is assigned to the collection', async(() => {
76104
TestBed.overrideComponent(TestContainerComponent, {
77105
set: {

0 commit comments

Comments
 (0)