Skip to content

Commit a6c73c0

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Add test.
1 parent 1bd817d commit a6c73c0

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.spec.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,66 @@ describe('IgxHierarchicalGrid Row Islands #hGrid', () => {
919919
expect(childGrid1.rowList.length).toEqual(1);
920920
expect(childGrid1.gridAPI.get_cell_by_index(0, 'ProductName').nativeElement.innerText).toEqual('Child12 ProductName');
921921
}));
922+
923+
it('should allow binding to complex object.', fakeAsync(() => {
924+
const rowIsland1 = fixture.componentInstance.rowIsland1 as IgxRowIslandComponent;
925+
const rowIsland2 = fixture.componentInstance.rowIsland2 as IgxRowIslandComponent;
926+
rowIsland1.key = 'childData.Records';
927+
rowIsland2.key = 'childData2.Records';
928+
929+
hierarchicalGrid.childLayoutKeys = ['childData.Records', 'childData2.Records'];
930+
const complexObjData = [
931+
{
932+
ID: 1,
933+
ProductName : 'Parent Name',
934+
childData: {
935+
Records: [
936+
{
937+
ID: 11,
938+
ProductName : 'Child11 ProductName'
939+
},
940+
{
941+
ID: 12,
942+
ProductName : 'Child12 ProductName'
943+
}
944+
]
945+
},
946+
childData2: {
947+
Records: [
948+
{
949+
ID: 21,
950+
Col1: 'Child21 Col1',
951+
Col2: 'Child21 Col2',
952+
Col3: 'Child21 Col3'
953+
},
954+
{
955+
ID: 22,
956+
Col1: 'Child22 Col1',
957+
Col2: 'Child22 Col2',
958+
Col3: 'Child22 Col3'
959+
}
960+
]
961+
}
962+
}
963+
];
964+
fixture.componentInstance.data = complexObjData;
965+
fixture.detectChanges();
966+
967+
const row = hierarchicalGrid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
968+
UIInteractions.simulateClickAndSelectEvent(row.expander);
969+
tick();
970+
fixture.detectChanges();
971+
972+
const childGrids = fixture.debugElement.queryAll(By.css('igx-child-grid-row'));
973+
const childGrid1 = childGrids[0].query(By.css('igx-hierarchical-grid')).componentInstance;
974+
const childGrid2 = childGrids[1].query(By.css('igx-hierarchical-grid')).componentInstance;
975+
expect(childGrid1.data.length).toEqual(2);
976+
expect(childGrid2.data.length).toEqual(2);
977+
978+
expect(childGrid1.data[0].ID).toBe(11);
979+
expect(childGrid2.data[0].ID).toBe(21);
980+
})
981+
);
922982
});
923983

924984
describe('IgxHierarchicalGrid Children Sizing #hGrid', () => {

0 commit comments

Comments
 (0)