@@ -686,12 +686,14 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
686686 fixture . detectChanges ( ) ;
687687 const childGrids = hierarchicalGrid . gridAPI . getChildGrids ( false ) ;
688688 const childRows = fixture . debugElement . queryAll ( By . directive ( IgxChildGridRowComponent ) ) ;
689- expect ( childGrids . length ) . toBe ( 2 ) ;
690- expect ( childRows . length ) . toBe ( 2 ) ;
689+ expect ( childGrids . length ) . toBe ( 3 ) ;
690+ expect ( childRows . length ) . toBe ( 3 ) ;
691691 const ri1 = fixture . componentInstance . rowIsland1 ;
692692 const ri2 = fixture . componentInstance . rowIsland2 ;
693+ const ri3 = fixture . componentInstance . rowIsland3 ;
693694 expect ( childRows [ 0 ] . componentInstance . layout ) . toBe ( ri1 ) ;
694695 expect ( childRows [ 1 ] . componentInstance . layout ) . toBe ( ri2 ) ;
696+ expect ( childRows [ 2 ] . componentInstance . layout ) . toBe ( ri3 ) ;
695697 } ) ;
696698
697699 it ( 'should display correct data for sibling row islands' , ( ) => {
@@ -865,18 +867,21 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
865867 fixture . detectChanges ( ) ;
866868
867869 const children = hierarchicalGrid . gridAPI . getChildGrids ( true ) ;
868- expect ( children . length ) . toBe ( 2 ) ;
870+ expect ( children . length ) . toBe ( 3 ) ;
869871 const child1 = children [ 0 ] as IgxHierarchicalGridComponent ;
870872 const child2 = children [ 1 ] as IgxHierarchicalGridComponent ;
873+ const child3 = children [ 2 ] as IgxHierarchicalGridComponent ;
871874 expect ( child1 . _destroyed ) . toBeFalsy ( ) ;
872875 expect ( child2 . _destroyed ) . toBeFalsy ( ) ;
876+ expect ( child3 . _destroyed ) . toBeFalsy ( ) ;
873877 hierarchicalGrid . verticalScrollContainer . scrollTo ( hierarchicalGrid . dataView . length - 1 ) ;
874878 await wait ( ) ;
875879 fixture . detectChanges ( ) ;
876880
877881 // check that we have child is not destroyed
878882 expect ( child1 . _destroyed ) . toBeFalsy ( ) ;
879883 expect ( child2 . _destroyed ) . toBeFalsy ( ) ;
884+ expect ( child3 . _destroyed ) . toBeFalsy ( ) ;
880885
881886 // destroy hgrid
882887 fixture . destroy ( ) ;
@@ -1119,6 +1124,32 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
11191124 expect ( getterSpy ) . toHaveBeenCalledTimes ( 7 ) ;
11201125 expect ( summaryCell . textContent . trim ( ) ) . toEqual ( '' ) ;
11211126 } ) ) ;
1127+
1128+ it ( 'should verify gridCreated and gridInitialized events emit correct parentRowData for grids with and without data.' , ( ) => {
1129+ const row = hierarchicalGrid . gridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
1130+ const ri1 = fixture . componentInstance . rowIsland1 ;
1131+ const ri3 = fixture . componentInstance . rowIsland3 ;
1132+
1133+ spyOn ( ri1 . gridCreated , 'emit' ) . and . callThrough ( ) ;
1134+ spyOn ( ri1 . gridInitialized , 'emit' ) . and . callThrough ( ) ;
1135+ spyOn ( ri3 . gridCreated , 'emit' ) . and . callThrough ( ) ;
1136+ spyOn ( ri3 . gridInitialized , 'emit' ) . and . callThrough ( ) ;
1137+
1138+ UIInteractions . simulateClickAndSelectEvent ( row . expander ) ;
1139+ fixture . detectChanges ( ) ;
1140+
1141+ // Verify parentRowData is undefined for grids with existing data
1142+ expect ( ri1 . gridCreated . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1143+ expect ( ri1 . gridCreated . emit ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { parentRowData : undefined } ) ) ;
1144+ expect ( ri1 . gridInitialized . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1145+ expect ( ri1 . gridInitialized . emit ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { parentRowData : undefined } ) ) ;
1146+
1147+ // Verify parentRowData is defined for grids without data
1148+ expect ( ri3 . gridCreated . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1149+ expect ( ri3 . gridCreated . emit ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { parentRowData : row . data } ) ) ;
1150+ expect ( ri3 . gridInitialized . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1151+ expect ( ri3 . gridInitialized . emit ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { parentRowData : row . data } ) ) ;
1152+ } ) ;
11221153 } ) ;
11231154
11241155 describe ( 'IgxHierarchicalGrid Children Sizing #hGrid' , ( ) => {
@@ -1984,12 +2015,14 @@ export class IgxHierarchicalGridTestBaseComponent {
19842015 <igx-column field="Col2"></igx-column>
19852016 <igx-column field="Col3"></igx-column>
19862017 </igx-row-island>
2018+ <igx-row-island [key]="'noData'" #rowIsland3></igx-row-island>
19872019 </igx-hierarchical-grid>` ,
19882020 imports : [ IgxHierarchicalGridComponent , IgxColumnComponent , IgxRowIslandComponent ]
19892021} )
19902022export class IgxHierarchicalGridMultiLayoutComponent extends IgxHierarchicalGridTestBaseComponent {
19912023 @ViewChild ( 'rowIsland1' , { read : IgxRowIslandComponent , static : true } ) public rowIsland1 : IgxRowIslandComponent ;
19922024 @ViewChild ( 'rowIsland2' , { read : IgxRowIslandComponent , static : true } ) public override rowIsland2 : IgxRowIslandComponent ;
2025+ @ViewChild ( 'rowIsland3' , { read : IgxRowIslandComponent , static : true } ) public rowIsland3 : IgxRowIslandComponent ;
19932026 public height = '100px' ;
19942027 public toggleColumns = true ;
19952028}
0 commit comments