Skip to content

Commit 81ae277

Browse files
authored
Merge pull request #6878 from IgniteUI/mkirova/row-pinning-sort
feat(igxGrid): Row Pinning + Sorting. Adding test.
2 parents e54b6f1 + 328cd7e commit 81ae277

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

projects/igniteui-angular/src/lib/grids/grid/row-pinning.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { configureTestSuite } from '../../test-utils/configure-suite';
88
import { ColumnPinningPosition, RowPinningPosition } from '../common/enums';
99
import { IPinningConfig } from '../common/grid.interface';
1010
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
11+
import { SortingDirection } from '../../data-operations/sorting-expression.interface';
1112
import { IgxGridTransaction } from '../tree-grid';
1213
import { IgxTransactionService } from '../../services';
1314

@@ -220,6 +221,26 @@ describe('Row Pinning #grid', () => {
220221
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[0]);
221222
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
222223
});
224+
225+
it('should apply sorting to both pinned and unpinned rows.', () => {
226+
grid.getRowByIndex(1).pin();
227+
grid.getRowByIndex(5).pin();
228+
fix.detectChanges();
229+
230+
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[1]);
231+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[5]);
232+
233+
grid.sort({ fieldName: 'ID', dir: SortingDirection.Desc, ignoreCase: false });
234+
fix.detectChanges();
235+
236+
// check pinned rows data is sorted
237+
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[5]);
238+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
239+
240+
// check unpinned rows data is sorted
241+
const lastIndex = fix.componentInstance.data.length - 1;
242+
expect(grid.getRowByIndex(2).rowID).toBe(fix.componentInstance.data[lastIndex]);
243+
});
223244
});
224245

225246
describe(' Editing ', () => {

0 commit comments

Comments
 (0)