@@ -30,7 +30,7 @@ describe('Row Pinning #grid', () => {
3030 IgxGridModule
3131 ]
3232 } )
33- . compileComponents ( ) ;
33+ . compileComponents ( ) ;
3434 } ) ) ;
3535
3636 describe ( '' , ( ) => {
@@ -71,7 +71,7 @@ describe('Row Pinning #grid', () => {
7171
7272 // 2 records pinned + 2px border
7373 expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
74- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
74+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
7575 expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
7676 } ) ;
7777
@@ -110,7 +110,7 @@ describe('Row Pinning #grid', () => {
110110
111111 // 2 records pinned + 2px border
112112 expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
113- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
113+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
114114 expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
115115 } ) ;
116116
@@ -195,31 +195,63 @@ describe('Row Pinning #grid', () => {
195195 } ) ;
196196
197197 it ( 'should pin/unpin via row pinned setter.' , ( ) => {
198- // pin 2nd row
199- let row = grid . getRowByIndex ( 1 ) ;
200- row . pinned = true ;
201- fix . detectChanges ( ) ;
202-
203- expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
204- let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
205- expect ( pinRowContainer . length ) . toBe ( 1 ) ;
206- expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
207- expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
208-
209- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
210- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
211-
212- // unpin
213- row = grid . getRowByIndex ( 0 ) ;
214- row . pinned = false ;
215- fix . detectChanges ( ) ;
216-
217- expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
218- pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
219- expect ( pinRowContainer . length ) . toBe ( 0 ) ;
220-
221- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
222- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
198+ // pin 2nd row
199+ let row = grid . getRowByIndex ( 1 ) ;
200+ row . pinned = true ;
201+ fix . detectChanges ( ) ;
202+
203+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
204+ let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
205+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
206+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
207+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
208+
209+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
210+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
211+
212+ // unpin
213+ row = grid . getRowByIndex ( 0 ) ;
214+ row . pinned = false ;
215+ fix . detectChanges ( ) ;
216+
217+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
218+ pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
219+ expect ( pinRowContainer . length ) . toBe ( 0 ) ;
220+
221+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
222+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
223+ } ) ;
224+
225+ it ( 'should pin rows when columns are grouped.' , ( ) => {
226+ // pin 1st and 2nd data row
227+ grid . pinRow ( fix . componentInstance . data [ 0 ] ) ;
228+ grid . pinRow ( fix . componentInstance . data [ 1 ] ) ;
229+ fix . detectChanges ( ) ;
230+
231+ // group by string column
232+ grid . groupBy ( {
233+ fieldName : 'ContactTitle' , dir : SortingDirection . Desc , ignoreCase : false
234+ } ) ;
235+ fix . detectChanges ( ) ;
236+
237+ expect ( grid . pinnedRows . length ) . toBe ( 2 ) ;
238+
239+ // verify rows
240+ const groupRows = grid . groupsRowList . toArray ( ) ;
241+ const dataRows = grid . dataRowList . toArray ( ) ;
242+
243+ expect ( groupRows . length ) . toEqual ( 2 ) ;
244+ expect ( dataRows . length ) . toEqual ( 7 ) ;
245+ expect ( groupRows [ 0 ] . groupRow . records [ 0 ] . ID ) . toEqual ( 'AROUT' ) ;
246+
247+ // pin 4th data row with ID:AROUT
248+ grid . pinRow ( fix . componentInstance . data [ 3 ] ) ;
249+ fix . detectChanges ( ) ;
250+
251+ expect ( grid . pinnedRows . length ) . toBe ( 3 ) ;
252+
253+ // make sure the pinned row is out of the first groupBy group
254+ expect ( groupRows [ 0 ] . groupRow . records [ 0 ] . ID ) . toEqual ( 'BLAUS' ) ;
223255 } ) ;
224256
225257 it ( 'should apply sorting to both pinned and unpinned rows.' , ( ) => {
@@ -281,7 +313,7 @@ describe('Row Pinning #grid', () => {
281313
282314 it ( 'should allow pinning added row.' , ( ) => {
283315
284- grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
316+ grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
285317 fix . detectChanges ( ) ;
286318
287319 grid . pinRow ( 'Test' ) ;
0 commit comments