Skip to content

Commit da493f1

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Attempt to fix tests.
1 parent 01b7c61 commit da493f1

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
11951195
}
11961196
}
11971197
if (this.igxForScrollOrientation === 'vertical') {
1198+
// reset width to force reflow.
1199+
this.scrollComponent.nativeElement.style.width = '';
11981200
this.scrollComponent.nativeElement.style.height = parseInt(this.igxForContainerSize, 10) + 'px';
11991201
this.scrollComponent.size = this._calcHeight();
12001202
if ( this.scrollComponent.size <= parseInt(this.igxForContainerSize, 10)) {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,10 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
549549

550550
const grid = fixture.componentInstance.grid;
551551
const headers: DebugElement[] = fixture.debugElement.queryAll(By.css(COLUMN_HEADER_GROUP_CLASS));
552-
const expectedHeight = fixture.debugElement.query(By.css('igx-grid')).nativeElement.getBoundingClientRect().height -
552+
let expectedHeight = fixture.debugElement.query(By.css('igx-grid')).nativeElement.getBoundingClientRect().height -
553553
grid.nativeElement.querySelector('.igx-grid__thead').getBoundingClientRect().height -
554-
grid.nativeElement.querySelector('.igx-grid__tfoot').getBoundingClientRect().height;
554+
grid.nativeElement.querySelector('.igx-grid__tfoot').getBoundingClientRect().height -
555+
grid.nativeElement.querySelector('.igx-grid__scroll').getBoundingClientRect().height;
555556

556557
expect(grid.calcHeight).toEqual(expectedHeight);
557558
expect(grid.columns[0].width).toEqual('100px');
@@ -574,8 +575,11 @@ describe('IgxGrid - Deferred Column Resizing #grid', () => {
574575
const hScroll = fixture.componentInstance.grid.headerContainer.getScroll();
575576
const hScrollVisible = hScroll.offsetWidth < hScroll.children[0].offsetWidth;
576577

577-
// Should 243 - 18, because the horizontal scrollbar has 18px height
578-
expect(grid.calcHeight).toEqual(expectedHeight - 18);
578+
expectedHeight = fixture.debugElement.query(By.css('igx-grid')).nativeElement.getBoundingClientRect().height -
579+
grid.nativeElement.querySelector('.igx-grid__thead').getBoundingClientRect().height -
580+
grid.nativeElement.querySelector('.igx-grid__tfoot').getBoundingClientRect().height -
581+
grid.nativeElement.querySelector('.igx-grid__scroll').getBoundingClientRect().height;
582+
expect(grid.calcHeight).toEqual(expectedHeight);
579583
expect(hScrollVisible).toBe(true);
580584
});
581585

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,8 +1625,12 @@ describe('IgxGrid Component Tests #grid', () => {
16251625
const headers = fix.debugElement.queryAll(By.css(COLUMN_HEADER_CLASS));
16261626
expect(headers.length).toBe(4);
16271627
const gridBody = fix.debugElement.query(By.css(TBODY_CLASS));
1628+
const expectedHeight = fix.debugElement.query(By.css('igx-grid')).nativeElement.getBoundingClientRect().height -
1629+
grid.nativeElement.querySelector('.igx-grid__thead').getBoundingClientRect().height -
1630+
grid.nativeElement.querySelector('.igx-grid__tfoot').getBoundingClientRect().height -
1631+
grid.nativeElement.querySelector('.igx-grid__scroll').getBoundingClientRect().height;
16281632
expect(parseInt(window.getComputedStyle(gridBody.nativeElement).width, 10) + grid.scrollWidth).toBe(500);
1629-
expect(parseInt(window.getComputedStyle(gridBody.nativeElement).height, 10)).toBe(230);
1633+
expect(parseInt(window.getComputedStyle(gridBody.nativeElement).height, 10)).toBe(expectedHeight);
16301634
});
16311635

16321636
it('IgxTabs: should initialize a grid with correct height when paging and summaries are enabled', async () => {
@@ -1644,7 +1648,11 @@ describe('IgxGrid Component Tests #grid', () => {
16441648
const summaries = fix.debugElement.queryAll(By.css('igx-grid-summary-cell'));
16451649
expect(headers.length).toBe(4);
16461650
expect(summaries.length).toBe(4);
1647-
expect(parseInt(window.getComputedStyle(gridBody.nativeElement).height, 10)).toBe(139);
1651+
const expectedHeight = fix.debugElement.query(By.css('igx-grid')).nativeElement.getBoundingClientRect().height -
1652+
grid.nativeElement.querySelector('.igx-grid__thead').getBoundingClientRect().height -
1653+
grid.nativeElement.querySelector('.igx-grid__tfoot').getBoundingClientRect().height -
1654+
grid.nativeElement.querySelector('.igx-grid__scroll').getBoundingClientRect().height;
1655+
expect(parseInt(window.getComputedStyle(gridBody.nativeElement).height, 10)).toBe(expectedHeight);
16481656
expect(parseInt(window.getComputedStyle(paging.nativeElement).height, 10)).toBe(36);
16491657
});
16501658

@@ -1677,8 +1685,12 @@ describe('IgxGrid Component Tests #grid', () => {
16771685
await wait(100);
16781686
grid.cdr.detectChanges();
16791687
const gridBody = fix.debugElement.query(By.css(TBODY_CLASS));
1680-
expect(grid.calcHeight).toBe(230);
1681-
expect(parseInt(window.getComputedStyle(gridBody.nativeElement).height, 10)).toBe(230);
1688+
const expectedHeight = fix.debugElement.query(By.css('igx-grid')).nativeElement.getBoundingClientRect().height -
1689+
grid.nativeElement.querySelector('.igx-grid__thead').getBoundingClientRect().height -
1690+
grid.nativeElement.querySelector('.igx-grid__tfoot').getBoundingClientRect().height -
1691+
grid.nativeElement.querySelector('.igx-grid__scroll').getBoundingClientRect().height;
1692+
expect(grid.calcHeight).toBe(expectedHeight);
1693+
expect(parseInt(window.getComputedStyle(gridBody.nativeElement).height, 10)).toBe(expectedHeight);
16821694
expect(parseInt(window.getComputedStyle(grid.nativeElement).height, 10)).toBe(300);
16831695
});
16841696
});

0 commit comments

Comments
 (0)