@@ -8,6 +8,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
88import { ColumnPinningPosition , RowPinningPosition } from '../common/enums' ;
99import { IPinningConfig } from '../common/grid.interface' ;
1010import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
11+ import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
1112import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
1213import { IgxGridTransaction } from '../tree-grid' ;
1314import { IgxTransactionService } from '../../services' ;
@@ -24,6 +25,7 @@ describe('Row Pinning #grid', () => {
2425 TestBed . configureTestingModule ( {
2526 declarations : [
2627 GridRowPinningComponent ,
28+ GridRowPinningWithMDVComponent ,
2729 GridRowPinningWithTransactionsComponent
2830 ] ,
2931 imports : [
@@ -350,6 +352,40 @@ describe('Row Pinning #grid', () => {
350352 expect ( grid . getRowByIndex ( 2 ) . rowID ) . toBe ( fix . componentInstance . data [ lastIndex ] ) ;
351353 } ) ;
352354 } ) ;
355+ describe ( 'Row pinning with Master Detail View' , ( ) => {
356+ beforeEach ( fakeAsync ( ( ) => {
357+ fix = TestBed . createComponent ( GridRowPinningWithMDVComponent ) ;
358+ fix . detectChanges ( ) ;
359+ grid = fix . componentInstance . instance ;
360+ tick ( ) ;
361+ fix . detectChanges ( ) ;
362+ } ) ) ;
363+
364+ it ( 'should be in view when expanded and pinning row to bottom of the grid.' , ( ) => {
365+ fix . componentInstance . pinningConfig = { columns : ColumnPinningPosition . Start , rows : RowPinningPosition . Bottom } ;
366+ fix . detectChanges ( ) ;
367+ // pin 1st row
368+ const row = grid . getRowByIndex ( 0 ) ;
369+ row . pinned = true ;
370+ fix . detectChanges ( ) ;
371+
372+ GridFunctions . toggleMasterRow ( fix , grid . pinnedRows [ 0 ] ) ;
373+ fix . detectChanges ( ) ;
374+
375+
376+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
377+
378+ const firstRowIconName = GridFunctions . getRowExpandIconName ( grid . pinnedRows [ 0 ] ) ;
379+ const firstRowDetail = GridFunctions . getMasterRowDetail ( grid . pinnedRows [ 0 ] ) ;
380+ expect ( grid . expansionStates . size ) . toEqual ( 1 ) ;
381+ expect ( grid . expansionStates . has ( grid . pinnedRows [ 0 ] . rowID ) ) . toBeTruthy ( ) ;
382+ expect ( grid . expansionStates . get ( grid . pinnedRows [ 0 ] . rowID ) ) . toBeTruthy ( ) ;
383+ expect ( firstRowIconName ) . toEqual ( 'expand_more' ) ;
384+
385+ // check last pinned and expanded is fully in view
386+ expect ( firstRowDetail . getBoundingClientRect ( ) . bottom - grid . tbody . nativeElement . getBoundingClientRect ( ) . bottom ) . toBe ( 0 ) ;
387+ } ) ;
388+ } ) ;
353389
354390 describe ( ' Editing ' , ( ) => {
355391 beforeEach ( fakeAsync ( ( ) => {
@@ -451,6 +487,25 @@ export class GridRowPinningComponent {
451487 public instance : IgxGridComponent ;
452488}
453489
490+ @Component ( {
491+ template : `
492+ <igx-grid
493+ [pinning]='pinningConfig'
494+ [width]='"800px"'
495+ [height]='"500px"'
496+ [data]="data"
497+ [autoGenerate]="true">
498+ <ng-template igxGridDetail let-dataItem>
499+ <div>
500+ <div><span class='categoryStyle'>Country:</span> {{dataItem.Country}}</div>
501+ <div><span class='categoryStyle'>City:</span> {{dataItem.City}}</div>
502+ <div><span class='categoryStyle'>Address:</span> {{dataItem.Address}}</div>
503+ </div>
504+ </ng-template>
505+ </igx-grid>`
506+ } )
507+ export class GridRowPinningWithMDVComponent extends GridRowPinningComponent { }
508+
454509
455510@Component ( {
456511 template : `
@@ -465,6 +520,4 @@ export class GridRowPinningComponent {
465520 ` ,
466521 providers : [ { provide : IgxGridTransaction , useClass : IgxTransactionService } ]
467522} )
468- export class GridRowPinningWithTransactionsComponent extends GridRowPinningComponent {
469- public data = SampleTestData . contactInfoDataFull ( ) ;
470- }
523+ export class GridRowPinningWithTransactionsComponent extends GridRowPinningComponent { }
0 commit comments