@@ -31,7 +31,7 @@ describe('Row Pinning #grid', () => {
3131 IgxGridModule
3232 ]
3333 } )
34- . compileComponents ( ) ;
34+ . compileComponents ( ) ;
3535 } ) ) ;
3636
3737 describe ( '' , ( ) => {
@@ -72,7 +72,7 @@ describe('Row Pinning #grid', () => {
7272
7373 // 2 records pinned + 2px border
7474 expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
75- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
75+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
7676 expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
7777 } ) ;
7878
@@ -111,7 +111,7 @@ describe('Row Pinning #grid', () => {
111111
112112 // 2 records pinned + 2px border
113113 expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
114- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
114+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
115115 expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
116116 } ) ;
117117
@@ -196,31 +196,63 @@ describe('Row Pinning #grid', () => {
196196 } ) ;
197197
198198 it ( 'should pin/unpin via row pinned setter.' , ( ) => {
199- // pin 2nd row
200- let row = grid . getRowByIndex ( 1 ) ;
201- row . pinned = true ;
202- fix . detectChanges ( ) ;
203-
204- expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
205- let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
206- expect ( pinRowContainer . length ) . toBe ( 1 ) ;
207- expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
208- expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
209-
210- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
211- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
212-
213- // unpin
214- row = grid . getRowByIndex ( 0 ) ;
215- row . pinned = false ;
216- fix . detectChanges ( ) ;
217-
218- expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
219- pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
220- expect ( pinRowContainer . length ) . toBe ( 0 ) ;
221-
222- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
223- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
199+ // pin 2nd row
200+ let row = grid . getRowByIndex ( 1 ) ;
201+ row . pinned = true ;
202+ fix . detectChanges ( ) ;
203+
204+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
205+ let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
206+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
207+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
208+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
209+
210+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
211+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
212+
213+ // unpin
214+ row = grid . getRowByIndex ( 0 ) ;
215+ row . pinned = false ;
216+ fix . detectChanges ( ) ;
217+
218+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
219+ pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
220+ expect ( pinRowContainer . length ) . toBe ( 0 ) ;
221+
222+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
223+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
224+ } ) ;
225+
226+ it ( 'should pin rows when columns are grouped.' , ( ) => {
227+ // pin 1st and 2nd data row
228+ grid . pinRow ( fix . componentInstance . data [ 0 ] ) ;
229+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
230+ fix . detectChanges ( ) ;
231+
232+ // group by string column
233+ grid . groupBy ( {
234+ fieldName : 'ContactTitle' , dir : SortingDirection . Desc , ignoreCase : false
235+ } ) ;
236+ fix . detectChanges ( ) ;
237+
238+ expect ( grid . pinnedRows . length ) . toBe ( 2 ) ;
239+
240+ // verify rows
241+ const groupRows = grid . groupsRowList . toArray ( ) ;
242+ const dataRows = grid . dataRowList . toArray ( ) ;
243+
244+ expect ( groupRows . length ) . toEqual ( 2 ) ;
245+ expect ( dataRows . length ) . toEqual ( 7 ) ;
246+ expect ( groupRows [ 0 ] . groupRow . records [ 0 ] . ID ) . toEqual ( 'AROUT' ) ;
247+
248+ // pin 4th data row with ID:AROUT
249+ grid . pinRow ( fix . componentInstance . data [ 3 ] ) ;
250+ fix . detectChanges ( ) ;
251+
252+ expect ( grid . pinnedRows . length ) . toBe ( 3 ) ;
253+
254+ // make sure the pinned row is out of the first groupBy group
255+ expect ( groupRows [ 0 ] . groupRow . records [ 0 ] . ID ) . toEqual ( 'BLAUS' ) ;
224256 } ) ;
225257
226258 it ( 'should apply filtering to both pinned and unpinned rows.' , ( ) => {
@@ -344,7 +376,7 @@ describe('Row Pinning #grid', () => {
344376
345377 it ( 'should allow pinning added row.' , ( ) => {
346378
347- grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
379+ grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
348380 fix . detectChanges ( ) ;
349381
350382 grid . pinRow ( 'Test' ) ;
0 commit comments