Skip to content

Commit 092abbe

Browse files
committed
feat(*): Add tests. Fix intial horizontal scrollbar.
1 parent 4c74b65 commit 092abbe

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
291291
columns = columns.concat(allChildren);
292292
}
293293
});
294+
this.reflow();
294295
return columns;
295296
}
296297

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { Component, ViewChild } from '@angular/core';
2+
import { fakeAsync, TestBed } from '@angular/core/testing';
3+
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
4+
import { IgxNumberSummaryOperand, IgxPivotGridComponent, IgxPivotGridModule, IPivotConfiguration } from 'igniteui-angular';
5+
import { configureTestSuite } from '../../test-utils/configure-suite';
6+
7+
describe('Basic IgxPivotGrid #pivotGrid', () => {
8+
let fixture;
9+
configureTestSuite((() => {
10+
TestBed.configureTestingModule({
11+
declarations: [
12+
IgxPivotGridTestBaseComponent
13+
],
14+
imports: [
15+
NoopAnimationsModule, IgxPivotGridModule]
16+
});
17+
}));
18+
19+
beforeEach(fakeAsync(() => {
20+
fixture = TestBed.createComponent(IgxPivotGridTestBaseComponent);
21+
fixture.detectChanges();
22+
}));
23+
24+
it('should apply formatter and dataType from measures', () => {
25+
const pivotGrid = fixture.componentInstance.pivotGrid;
26+
const actualFormatterValue = pivotGrid.rowList.first.cells.first.title;
27+
expect(actualFormatterValue).toEqual('774$');
28+
const actualDataTypeValue = pivotGrid.rowList.first.cells.last.title;
29+
expect(actualDataTypeValue).toEqual('$28.86');
30+
});
31+
32+
it('should apply css class to cells from measures', () => {
33+
const pivotGrid = fixture.componentInstance.pivotGrid;
34+
const cells = pivotGrid.rowList.first.cells;
35+
expect(cells.first.nativeElement.classList).toContain('test');
36+
expect(cells.last.nativeElement.classList).not.toContain('test');
37+
});
38+
});
39+
40+
41+
@Component({
42+
template: `
43+
<igx-pivot-grid #grid [data]="data" [pivotConfiguration]="pivotConfigHierarchy">
44+
</igx-pivot-grid>`
45+
})
46+
export class IgxPivotGridTestBaseComponent {
47+
public data;
48+
49+
public callback = (rowData: any, columnKey: any) => rowData[columnKey] >= 5;
50+
public callback1 = (rowData: any, columnKey: any) => rowData[columnKey] < 5;
51+
52+
public cellClasses = {
53+
test: this.callback,
54+
test2: this.callback1
55+
};
56+
57+
@ViewChild('grid', { read: IgxPivotGridComponent, static: true }) public pivotGrid: IgxPivotGridComponent;
58+
59+
public pivotConfigHierarchy: IPivotConfiguration = {
60+
columns: [{
61+
member: 'Country',
62+
enabled: true,
63+
childLevels: []
64+
},
65+
],
66+
rows: [{
67+
member: () => 'All',
68+
enabled: true,
69+
childLevels: [
70+
{
71+
fieldName: 'ProductCategory',
72+
member: (data) => data.ProductCategory,
73+
enabled: true,
74+
childLevels: []
75+
}
76+
]
77+
}],
78+
values: [
79+
{
80+
member: 'UnitsSold',
81+
aggregate: IgxNumberSummaryOperand.sum,
82+
enabled: true,
83+
// dataType: 'currency',
84+
formatter: (value) => value ? value + '$' : undefined,
85+
styles: this.cellClasses
86+
},
87+
{
88+
member: 'UnitPrice',
89+
aggregate: IgxNumberSummaryOperand.sum,
90+
enabled: true,
91+
dataType: 'currency'
92+
}
93+
],
94+
filters: null
95+
};
96+
97+
constructor() {
98+
this.data = [{ ProductCategory: 'Clothing', UnitPrice: 12.81, SellerName: 'Stanley', Country: 'Bulgaria', Date: '01/01/2021', UnitsSold: 282 },
99+
{ ProductCategory: 'Clothing', UnitPrice: 49.57, SellerName: 'Elisa', Country: 'USA', Date: '01/05/2019', UnitsSold: 296 },
100+
{ ProductCategory: 'Bikes', UnitPrice: 3.56, SellerName: 'Lydia', Country: 'Uruguay', Date: '01/06/2020', UnitsSold: 68 },
101+
{ ProductCategory: 'Accessories', UnitPrice: 85.58, SellerName: 'David', Country: 'USA', Date: '04/07/2021', UnitsSold: 293 },
102+
{ ProductCategory: 'Components', UnitPrice: 18.13, SellerName: 'John', Country: 'USA', Date: '12/08/2021', UnitsSold: 240 },
103+
{ ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry', Country: 'Uruguay', Date: '05/12/2020', UnitsSold: 456 },
104+
{ ProductCategory: 'Clothing', UnitPrice: 16.05, SellerName: 'Walter', Country: 'Bulgaria', Date: '02/19/2020', UnitsSold: 492 }];
105+
106+
107+
}
108+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
<ng-template igxGridFor let-col [igxGridForOf]="unpinnedColumns | igxNotGrouped" [igxForScrollContainer]="grid.parentVirtDir" let-colIndex="index" [igxForSizePropName]='"calcPixelWidth"' [igxForScrollOrientation]="'horizontal'" [igxForContainerSize]='grid.unpinnedWidth' [igxForTrackBy]='grid.trackColumnChanges' #igxDirRef>
2222
<igx-grid-cell
23+
#cell
2324
class="igx-grid__td igx-grid__td--fw"
2425
[class.igx-grid__td--edited]="rowID | transactionState:col.field:grid.rowEditable:grid.transactions:grid.pipeTrigger:grid.gridAPI.crudService.cell:grid.gridAPI.crudService.row"
2526
[attr.aria-describedby]="gridID + '_' + col.field | igxStringReplace:'.':'_'"

0 commit comments

Comments
 (0)