Skip to content

Commit fc0f6ed

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Minor fixes and refactors for tests.
1 parent 66b718c commit fc0f6ed

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid-keyboard-nav.spec.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,36 @@ describe('IgxPivotGrid - Keyboard navigation #pivotGrid', () => {
112112
});
113113

114114
it('should allow navigating between column headers', () => {
115-
const [firstHeader, secondHeader] = fixture.debugElement.queryAll(
116-
By.css(`${PIVOT_HEADER_ROW} ${HEADER_CELL_CSS_CLASS}`));
115+
let firstHeader = fixture.debugElement.queryAll(
116+
By.css(`${PIVOT_HEADER_ROW} ${HEADER_CELL_CSS_CLASS}`))[0];
117117
UIInteractions.simulateClickAndSelectEvent(firstHeader);
118118
fixture.detectChanges();
119119

120+
firstHeader = fixture.debugElement.queryAll(
121+
By.css(`${PIVOT_HEADER_ROW} ${HEADER_CELL_CSS_CLASS}`))[0];
120122
GridFunctions.verifyHeaderIsFocused(firstHeader.parent);
121123
let activeCells = fixture.debugElement.queryAll(By.css(`${ACTIVE_CELL_CSS_CLASS}`));
122124
expect(activeCells.length).toBe(1);
123125

124-
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', firstHeader.nativeElement);
126+
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', pivotGrid.theadRow.nativeElement);
125127
fixture.detectChanges();
128+
129+
const secondHeader = fixture.debugElement.queryAll(
130+
By.css(`${PIVOT_HEADER_ROW} ${HEADER_CELL_CSS_CLASS}`))[1];
126131
GridFunctions.verifyHeaderIsFocused(secondHeader.parent);
127132
activeCells = fixture.debugElement.queryAll(By.css(`${ACTIVE_CELL_CSS_CLASS}`));
128133
expect(activeCells.length).toBe(1);
129134
});
130135

131136
it('should allow navigating from first to last column headers', async () => {
132-
const [firstHeader] = fixture.debugElement.queryAll(
133-
By.css(`${PIVOT_HEADER_ROW} ${HEADER_CELL_CSS_CLASS}`));
137+
let firstHeader = fixture.debugElement.queryAll(
138+
By.css(`${PIVOT_HEADER_ROW} ${HEADER_CELL_CSS_CLASS}`))[0];
134139
UIInteractions.simulateClickAndSelectEvent(firstHeader);
135140
fixture.detectChanges();
136141

142+
firstHeader = fixture.debugElement.queryAll(
143+
By.css(`${PIVOT_HEADER_ROW} ${HEADER_CELL_CSS_CLASS}`))[0];
144+
137145
GridFunctions.verifyHeaderIsFocused(firstHeader.parent);
138146
let activeCells = fixture.debugElement.queryAll(By.css(`${ACTIVE_CELL_CSS_CLASS}`));
139147
expect(activeCells.length).toBe(1);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
303303

304304
it('should sort on column for single row dimension.', () => {
305305
const pivotGrid = fixture.componentInstance.pivotGrid;
306-
const headerCell = GridFunctions.getColumnHeader('USA-UnitsSold', fixture);
306+
let headerCell = GridFunctions.getColumnHeader('USA-UnitsSold', fixture);
307307

308308
// sort asc
309309
GridFunctions.clickHeaderSortIcon(headerCell);
@@ -313,6 +313,7 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
313313
let columnValues = pivotGrid.dataView.map(x => x['USA-UnitsSold']);
314314
expect(columnValues).toEqual(expectedOrder);
315315

316+
headerCell = GridFunctions.getColumnHeader('USA-UnitsSold', fixture);
316317
// sort desc
317318
GridFunctions.clickHeaderSortIcon(headerCell);
318319
fixture.detectChanges();
@@ -322,6 +323,7 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
322323
expect(columnValues).toEqual(expectedOrder);
323324

324325
// remove sort
326+
headerCell = GridFunctions.getColumnHeader('USA-UnitsSold', fixture);
325327
GridFunctions.clickHeaderSortIcon(headerCell);
326328
fixture.detectChanges();
327329
expect(pivotGrid.sortingExpressions.length).toBe(0);

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-header-row.component.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent implem
129129

130130
protected populateDimensionRecursively(currentLevelColumns: ColumnType[], level = 0, res: any[]) {
131131
currentLevelColumns.forEach(col => {
132-
res[level].push(col);
133-
if (col.columnGroup && col.children.length > 0) {
134-
const visibleColumns = col.children.toArray().filter(x => !x.hidden);
135-
this.populateDimensionRecursively(visibleColumns, level + 1, res);
136-
} else if (level < this.totalDepth - 1) {
137-
for (let i = level + 1; i <= this.totalDepth - 1; i++) {
138-
res[i].push(col);
132+
if (res[level]) {
133+
res[level].push(col);
134+
if (col.columnGroup && col.children.length > 0) {
135+
const visibleColumns = col.children.toArray().filter(x => !x.hidden);
136+
this.populateDimensionRecursively(visibleColumns, level + 1, res);
137+
} else if (level < this.totalDepth - 1) {
138+
for (let i = level + 1; i <= this.totalDepth - 1; i++) {
139+
res[i].push(col);
140+
}
139141
}
140142
}
141143
});

0 commit comments

Comments
 (0)