Skip to content

Commit 16b77b8

Browse files
MKirovaMKirova
authored andcommitted
feat(igxGrid): Row Pinning + Sorting. Adding test.
1 parent ef772ce commit 16b77b8

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

1213
describe('Row Pinning #grid', () => {
1314
const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ';
@@ -216,6 +217,26 @@ describe('Row Pinning #grid', () => {
216217
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[0]);
217218
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
218219
});
220+
221+
it('should apply sorting to both pinned and unpinned rows.', () => {
222+
grid.getRowByIndex(1).pin();
223+
grid.getRowByIndex(5).pin();
224+
fix.detectChanges();
225+
226+
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[1]);
227+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[5]);
228+
229+
grid.sort({ fieldName: 'ID', dir: SortingDirection.Desc, ignoreCase: false });
230+
fix.detectChanges();
231+
232+
// check pinned rows data is sorted
233+
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[5]);
234+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
235+
236+
// check unpinned rows data is sorted
237+
const lastIndex = fix.componentInstance.data.length - 1;
238+
expect(grid.getRowByIndex(2).rowID).toBe(fix.componentInstance.data[lastIndex]);
239+
});
219240
});
220241
});
221242

0 commit comments

Comments
 (0)