@@ -416,6 +416,43 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
416
416
417
417
expect ( childGrid . calcWidth - 370 ) . toBeLessThan ( 3 ) ;
418
418
} ) ;
419
+
420
+ it ( 'should not expand children when hasChildrenKey is false for the row' , ( ) => {
421
+ hierarchicalGrid . hasChildrenKey = 'hasChild' ;
422
+ fixture . componentInstance . data = [
423
+ { ID : 1 , ProductName : 'Product: A1' , hasChild : false , childData : fixture . componentInstance . generateDataUneven ( 1 , 1 ) } ,
424
+ { ID : 2 , ProductName : 'Product: A2' , hasChild : true , childData : fixture . componentInstance . generateDataUneven ( 1 , 1 ) }
425
+ ] ;
426
+ fixture . detectChanges ( ) ;
427
+ const row1 = hierarchicalGrid . getRowByIndex ( 0 ) as IgxHierarchicalRowComponent ;
428
+ const rowElems = fixture . debugElement . queryAll ( By . directive ( IgxHierarchicalRowComponent ) ) ;
429
+ expect ( rowElems [ 0 ] . query ( By . css ( 'igx-icon' ) ) . nativeElement . innerText ) . toEqual ( '' ) ;
430
+ const row2 = hierarchicalGrid . getRowByIndex ( 1 ) as IgxHierarchicalRowComponent ;
431
+ expect ( rowElems [ 1 ] . query ( By . css ( 'igx-icon' ) ) . nativeElement . innerText ) . toEqual ( 'chevron_right' ) ;
432
+ hierarchicalGrid . expandRow ( row1 . rowData ) ;
433
+ hierarchicalGrid . expandRow ( row2 . rowData ) ;
434
+ expect ( row1 . expanded ) . toBe ( false ) ;
435
+ expect ( row2 . expanded ) . toBe ( true ) ;
436
+ } ) ;
437
+
438
+ it ( 'should not expand children when hasChildrenKey is false for the row and there is primaryKey' , ( ) => {
439
+ hierarchicalGrid . hasChildrenKey = 'hasChild' ;
440
+ hierarchicalGrid . primaryKey = 'ID' ;
441
+ fixture . componentInstance . data = [
442
+ { ID : 1 , ProductName : 'Product: A1' , hasChild : false , childData : fixture . componentInstance . generateDataUneven ( 1 , 1 ) } ,
443
+ { ID : 2 , ProductName : 'Product: A2' , hasChild : true , childData : fixture . componentInstance . generateDataUneven ( 1 , 1 ) }
444
+ ] ;
445
+ fixture . detectChanges ( ) ;
446
+ const row1 = hierarchicalGrid . getRowByIndex ( 0 ) as IgxHierarchicalRowComponent ;
447
+ const rowElems = fixture . debugElement . queryAll ( By . directive ( IgxHierarchicalRowComponent ) ) ;
448
+ expect ( rowElems [ 0 ] . query ( By . css ( 'igx-icon' ) ) . nativeElement . innerText ) . toEqual ( '' ) ;
449
+ const row2 = hierarchicalGrid . getRowByIndex ( 1 ) as IgxHierarchicalRowComponent ;
450
+ expect ( rowElems [ 1 ] . query ( By . css ( 'igx-icon' ) ) . nativeElement . innerText ) . toEqual ( 'chevron_right' ) ;
451
+ hierarchicalGrid . expandRow ( 1 ) ;
452
+ hierarchicalGrid . expandRow ( 2 ) ;
453
+ expect ( row1 . expanded ) . toBe ( false ) ;
454
+ expect ( row2 . expanded ) . toBe ( true ) ;
455
+ } ) ;
419
456
} ) ;
420
457
421
458
describe ( 'IgxHierarchicalGrid Row Islands #hGrid' , ( ) => {
0 commit comments