@@ -8,6 +8,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
8
8
import { ColumnPinningPosition , RowPinningPosition } from '../common/enums' ;
9
9
import { IPinningConfig } from '../common/grid.interface' ;
10
10
import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
11
+ import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
11
12
12
13
describe ( 'Row Pinning #grid' , ( ) => {
13
14
const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ' ;
@@ -216,6 +217,46 @@ describe('Row Pinning #grid', () => {
216
217
expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
217
218
expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
218
219
} ) ;
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
+ } ) ;
219
260
} ) ;
220
261
} ) ;
221
262
0 commit comments