Skip to content

Commit dd37b6d

Browse files
committed
test(row-pinning): Add test for row pinning and hiding #6640
1 parent 53cc019 commit dd37b6d

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,50 @@ describe('Row Pinning #grid', () => {
611611
verifyDOMMatchesLayoutSettings(gridUnpinnedRow, fix.componentInstance.colGroups);
612612
});
613613
});
614+
describe(' Hiding', () => {
615+
beforeEach(fakeAsync(() => {
616+
fix = TestBed.createComponent(GridRowPinningComponent);
617+
fix.detectChanges();
618+
grid = fix.componentInstance.instance;
619+
tick();
620+
fix.detectChanges();
621+
}));
622+
623+
it('should hide columns in pinned and unpinned area', () => {
624+
// pin 2nd data row
625+
grid.pinRow(fix.componentInstance.data[1]);
626+
fix.detectChanges();
627+
const hiddenCol = grid.columns[1];
628+
hiddenCol.hidden = true;
629+
fix.detectChanges();
630+
631+
const pinnedCells = grid.pinnedRows[0].cells;
632+
expect(pinnedCells.filter(cell => cell.column.field === hiddenCol.field).length).toBe(0);
633+
634+
const unpinnedCells = grid.rowList.first.cells;
635+
expect(unpinnedCells.filter(cell => cell.column.field === hiddenCol.field).length).toBe(0);
636+
637+
expect(pinnedCells.length).toBe(unpinnedCells.length);
638+
639+
const headerCells = grid.headerCellList;
640+
expect(headerCells.filter(cell => cell.column.field === hiddenCol.field).length).toBe(0);
641+
642+
expect(grid.pinnedRows.length).toBe(1);
643+
const pinRowContainer = fix.debugElement.queryAll(By.css(FIXED_ROW_CONTAINER));
644+
expect(pinRowContainer.length).toBe(1);
645+
expect(pinRowContainer[0].children.length).toBe(1);
646+
expect(pinRowContainer[0].children[0].context.rowID).toBe(fix.componentInstance.data[1]);
647+
expect(pinRowContainer[0].children[0].nativeElement).toBe(grid.getRowByIndex(0).nativeElement);
648+
649+
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[0]);
650+
expect(grid.getRowByIndex(2).rowID).toBe(fix.componentInstance.data[2]);
651+
652+
// 1 records pinned + 2px border
653+
expect(grid.pinnedRowHeight).toBe(grid.renderedRowHeight + 2);
654+
const expectedHeight = parseInt(grid.height, 10) - grid.pinnedRowHeight - 18 - grid.theadRow.nativeElement.offsetHeight;
655+
expect(grid.calcHeight - expectedHeight).toBeLessThanOrEqual(1);
656+
});
657+
});
614658
});
615659

616660
@Component({

src/app/grid-column-pinning/grid-column-pinning.sample.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class GridColumnPinningSampleComponent implements OnInit {
103103

104104
togglePinRow(index) {
105105
const rec = this.data[index];
106-
this.grid1.isRecordPinned(rec) ?
106+
!this.grid1.isRecordPinned(rec) ?
107107
this.grid1.pinRow(rec) :
108108
this.grid1.unpinRow(rec)
109109
}

src/app/grid-row-pinning/grid-row-pinning.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<igx-switch (change)='onRowChange()' style="padding-left: 10px"> Bottom Row Pinning toggle</igx-switch>
1010
<igx-switch (change)='onChange()' style="padding-left: 10px"> Right Column Pinning toggle</igx-switch>
1111
</div>
12-
<igx-grid [allowFiltering]='true' [primaryKey]='"ID"' [pinning]="pinningConfig" [showToolbar]='true' [columnPinning]='true' #grid1 [data]="data" [width]="'800px'" [height]="'500px'" [rowSelectable]="false">
12+
<igx-grid [allowFiltering]='true' [primaryKey]='"ID"' [pinning]="pinningConfig" [showToolbar]='true' [columnHiding]='true' [columnPinning]='true' #grid1 [data]="data" [width]="'800px'" [height]="'500px'" [rowSelectable]="false">
1313
<igx-column width='70px' [filterable]='false'>
1414
<ng-template igxCell let-cell="cell" let-val>
1515
<igx-icon class="pin-icon" (mousedown)="togglePining(cell.row, $event)">

0 commit comments

Comments
 (0)