Skip to content

Commit cd14fbc

Browse files
committed
Merge remote-tracking branch 'origin/master' into vmihalkov/groupby
2 parents c5f9133 + 81ae277 commit cd14fbc

File tree

1 file changed

+49
-29
lines changed

1 file changed

+49
-29
lines changed

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

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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,31 @@ 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]);
223223
});
224224

225225
it('should pin rows when columns are grouped.', () => {
@@ -253,6 +253,26 @@ describe('Row Pinning #grid', () => {
253253
// make sure the pinned row is out of the first groupBy group
254254
expect(groupRows[0].groupRow.records[0].ID).toEqual('BLAUS');
255255
});
256+
257+
it('should apply sorting to both pinned and unpinned rows.', () => {
258+
grid.getRowByIndex(1).pin();
259+
grid.getRowByIndex(5).pin();
260+
fix.detectChanges();
261+
262+
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[1]);
263+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[5]);
264+
265+
grid.sort({ fieldName: 'ID', dir: SortingDirection.Desc, ignoreCase: false });
266+
fix.detectChanges();
267+
268+
// check pinned rows data is sorted
269+
expect(grid.getRowByIndex(0).rowID).toBe(fix.componentInstance.data[5]);
270+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
271+
272+
// check unpinned rows data is sorted
273+
const lastIndex = fix.componentInstance.data.length - 1;
274+
expect(grid.getRowByIndex(2).rowID).toBe(fix.componentInstance.data[lastIndex]);
275+
});
256276
});
257277

258278
describe(' Editing ', () => {
@@ -293,7 +313,7 @@ describe('Row Pinning #grid', () => {
293313

294314
it('should allow pinning added row.', () => {
295315

296-
grid.addRow({ 'ID': 'Test', 'CompanyName': 'Test'});
316+
grid.addRow({ 'ID': 'Test', 'CompanyName': 'Test' });
297317
fix.detectChanges();
298318

299319
grid.pinRow('Test');

0 commit comments

Comments
 (0)