@@ -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' ;
1112import { IgxGridTransaction } from '../tree-grid' ;
1213import { IgxTransactionService } from '../../services' ;
1314
@@ -28,8 +29,7 @@ describe('Row Pinning #grid', () => {
2829 NoopAnimationsModule ,
2930 IgxGridModule
3031 ]
31- } )
32- . compileComponents ( ) ;
32+ } ) . compileComponents ( ) ;
3333 } ) ) ;
3434
3535 describe ( '' , ( ) => {
@@ -70,7 +70,7 @@ describe('Row Pinning #grid', () => {
7070
7171 // 2 records pinned + 2px border
7272 expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
73- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
73+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
7474 expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
7575 } ) ;
7676
@@ -109,7 +109,7 @@ describe('Row Pinning #grid', () => {
109109
110110 // 2 records pinned + 2px border
111111 expect ( grid . pinnedRowHeight ) . toBe ( 2 * grid . renderedRowHeight + 2 ) ;
112- const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
112+ const expectedHeight = parseInt ( grid . height , 10 ) - grid . pinnedRowHeight - 18 - grid . theadRow . nativeElement . offsetHeight ;
113113 expect ( grid . calcHeight - expectedHeight ) . toBeLessThanOrEqual ( 1 ) ;
114114 } ) ;
115115
@@ -194,39 +194,39 @@ describe('Row Pinning #grid', () => {
194194 } ) ;
195195
196196 it ( 'should pin/unpin via row pinned setter.' , ( ) => {
197- // pin 2nd row
198- let row = grid . getRowByIndex ( 1 ) ;
199- row . pinned = true ;
200- fix . detectChanges ( ) ;
201-
202- expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
203- let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
204- expect ( pinRowContainer . length ) . toBe ( 1 ) ;
205- expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
206- expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
207-
208- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
209- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
210-
211- // unpin
212- row = grid . getRowByIndex ( 0 ) ;
213- row . pinned = false ;
214- fix . detectChanges ( ) ;
215-
216- expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
217- pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
218- expect ( pinRowContainer . length ) . toBe ( 0 ) ;
219-
220- expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
221- expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
197+ // pin 2nd row
198+ let row = grid . getRowByIndex ( 1 ) ;
199+ row . pinned = true ;
200+ fix . detectChanges ( ) ;
201+
202+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
203+ let pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
204+ expect ( pinRowContainer . length ) . toBe ( 1 ) ;
205+ expect ( pinRowContainer [ 0 ] . children . length ) . toBe ( 1 ) ;
206+ expect ( pinRowContainer [ 0 ] . children [ 0 ] . context . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
207+
208+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
209+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
210+
211+ // unpin
212+ row = grid . getRowByIndex ( 0 ) ;
213+ row . pinned = false ;
214+ fix . detectChanges ( ) ;
215+
216+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
217+ pinRowContainer = fix . debugElement . queryAll ( By . css ( FIXED_ROW_CONTAINER ) ) ;
218+ expect ( pinRowContainer . length ) . toBe ( 0 ) ;
219+
220+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
221+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
222222 } ) ;
223223
224- it ( 'search should include pinned and unpinned rows.' , ( ) => {
224+ it ( 'should search in both pinned and unpinned rows.' , ( ) => {
225225 // pin 1st row
226226 let row = grid . getRowByIndex ( 0 ) ;
227227 row . pinned = true ;
228228 fix . detectChanges ( ) ;
229- expect ( grid . pinnedRecords . length ) . toBe ( 1 ) ;
229+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
230230
231231 let finds = grid . findNext ( 'mari' ) ;
232232 fix . detectChanges ( ) ;
@@ -247,15 +247,35 @@ describe('Row Pinning #grid', () => {
247247 row = grid . getRowByIndex ( 2 ) ;
248248 row . pinned = true ;
249249 fix . detectChanges ( ) ;
250- expect ( grid . pinnedRecords . length ) . toBe ( 2 ) ;
250+ expect ( grid . pinnedRows . length ) . toBe ( 2 ) ;
251251
252252 finds = grid . findNext ( 'antonio' ) ;
253253 fix . detectChanges ( ) ;
254254
255255 spans = fixNativeElement . querySelectorAll ( '.igx-highlight' ) ;
256256 expect ( spans . length ) . toBe ( 2 ) ;
257257 expect ( finds ) . toEqual ( 2 ) ;
258- } ) ;
258+ } ) ;
259+
260+ it ( 'should apply sorting to both pinned and unpinned rows.' , ( ) => {
261+ grid . getRowByIndex ( 1 ) . pin ( ) ;
262+ grid . getRowByIndex ( 5 ) . pin ( ) ;
263+ fix . detectChanges ( ) ;
264+
265+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
266+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 5 ] ) ;
267+
268+ grid . sort ( { fieldName : 'ID' , dir : SortingDirection . Desc , ignoreCase : false } ) ;
269+ fix . detectChanges ( ) ;
270+
271+ // check pinned rows data is sorted
272+ expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 5 ] ) ;
273+ expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
274+
275+ // check unpinned rows data is sorted
276+ const lastIndex = fix . componentInstance . data . length - 1 ;
277+ expect ( grid . getRowByIndex ( 2 ) . rowID ) . toBe ( fix . componentInstance . data [ lastIndex ] ) ;
278+ } ) ;
259279 } ) ;
260280
261281 describe ( ' Editing ' , ( ) => {
@@ -296,7 +316,7 @@ describe('Row Pinning #grid', () => {
296316
297317 it ( 'should allow pinning added row.' , ( ) => {
298318
299- grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
319+ grid . addRow ( { 'ID' : 'Test' , 'CompanyName' : 'Test' } ) ;
300320 fix . detectChanges ( ) ;
301321
302322 grid . pinRow ( 'Test' ) ;
0 commit comments