@@ -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 { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
1112
1213describe ( 'Row Pinning #grid' , ( ) => {
1314 const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ' ;
@@ -216,6 +217,46 @@ describe('Row Pinning #grid', () => {
216217 expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
217218 expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
218219 } ) ;
220+
221+ it ( 'pinned rows and groupby.' , ( ) => {
222+ // pin 1st and 2nd data row
223+ grid . pinRow ( fix . componentInstance . data [ 0 ] ) ;
224+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
225+ fix . detectChanges ( ) ;
226+
227+ // group by string column
228+ grid . groupBy ( {
229+ fieldName : 'ContactTitle' , dir : SortingDirection . Desc , ignoreCase : false
230+ } ) ;
231+ fix . detectChanges ( ) ;
232+
233+ expect ( grid . pinnedRecords . length ) . toBe ( 1 ) ;
234+ let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
235+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
236+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
237+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
238+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . nativeElement ) . toBe ( grid . getRowByIndex ( 0 ) . nativeElement ) ;
239+
240+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
241+ expect ( grid . getRowByIndex ( 2 ) . rowID ) . toBe ( fix . componentInstance . data [ 2 ] ) ;
242+
243+ // pin 3rd data row
244+ grid . pinRow ( fix . componentInstance . data [ 2 ] ) ;
245+ fix . detectChanges ( ) ;
246+
247+ pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
248+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 2 ) ;
249+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
250+ expect ( pinRowContainer [ 0 ] . children [ 1 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 2 ] ) ;
251+
252+ expect ( grid . getRowByIndex ( 2 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
253+ expect ( grid . getRowByIndex ( 3 ) . rowID ) . toBe ( fix . componentInstance . data [ 3 ] ) ;
254+
255+ // 2 records pinned + 2px border
256+ expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
257+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
258+ expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
259+ } ) ;
219260 } ) ;
220261} ) ;
221262
0 commit comments