Skip to content

Commit 5905ea5

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Adding test for right pinning and row selectors.
1 parent f53453c commit 5905ea5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,35 @@ describe('IgxGrid - Column Pinning to End', () => {
460460
expect(grid.pinnedWidth).toEqual(400);
461461
expect(grid.unpinnedWidth + grid.scrollWidth).toEqual(400);
462462
}));
463+
464+
it('should correctly pin column to right when row selectors are enabled.', fakeAsync(() => {
465+
const fix = TestBed.createComponent(GridRightPinningComponent);
466+
467+
tick();
468+
fix.detectChanges();
469+
const grid = fix.componentInstance.instance;
470+
grid.rowSelectable = true;
471+
tick();
472+
fix.detectChanges();
473+
474+
// check row DOM
475+
const row = grid.getRowByIndex(0).nativeElement;
476+
expect(row.children[0].className).toBe('igx-grid__cbx-selection');
477+
expect(row.children[1].className).toBe('igx-display-container');
478+
expect(row.children[2].getAttribute('aria-describedby')).toBe(grid.id + '_CompanyName');
479+
expect(row.children[3].getAttribute('aria-describedby')).toBe(grid.id + '_ContactName');
480+
481+
// check scrollbar DOM
482+
const scrBarStartSection = fix.debugElement.query(By.css('.igx-grid__scroll-start'));
483+
const scrBarMainSection = fix.debugElement.query(By.css('.igx-grid__scroll-main'));
484+
const scrBarEndSection = fix.debugElement.query(By.css('.igx-grid__scroll-end'));
485+
486+
expect(scrBarStartSection.nativeElement.offsetWidth).toEqual(grid.featureColumnsWidth());
487+
const pinnedColSum = grid.pinnedColumns.map(x => parseInt(x.calcWidth, 10)).reduce((x, y) => x + y);
488+
expect(scrBarEndSection.nativeElement.offsetWidth).toEqual(pinnedColSum);
489+
const expectedUnpinAreWidth = parseInt(grid.width, 10) - grid.featureColumnsWidth() - pinnedColSum - grid.scrollWidth;
490+
expect(scrBarMainSection.nativeElement.offsetWidth).toEqual(expectedUnpinAreWidth);
491+
}));
463492
});
464493

465494
/* tslint:disable */

0 commit comments

Comments
 (0)