Skip to content

Commit 3069b4d

Browse files
MKirovaMKirova
MKirova
authored and
MKirova
committed
Merge branch 'mdragnev/row-pinning-paging' of https://github.com/IgniteUI/igniteui-angular.git
2 parents 66dac20 + be4d335 commit 3069b4d

File tree

1 file changed

+61
-29
lines changed

1 file changed

+61
-29
lines changed

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

+61-29
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,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 page through unpinned collection with modified pageSize = pageSize - pinnedRows.lenght.', () => {
@@ -308,7 +340,7 @@ describe('Row Pinning #grid', () => {
308340

309341
it('should allow pinning added row.', () => {
310342

311-
grid.addRow({ 'ID': 'Test', 'CompanyName': 'Test'});
343+
grid.addRow({ 'ID': 'Test', 'CompanyName': 'Test' });
312344
fix.detectChanges();
313345

314346
grid.pinRow('Test');

0 commit comments

Comments
 (0)