Skip to content

Commit 2583aee

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Add aggregatorName tests.
1 parent b599d7e commit 2583aee

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,5 +2619,50 @@ describe('IgxPivotGrid #pivotGrid', () => {
26192619
expect(pivotGrid.rowList.length).toBe(1);
26202620
expect(pivotGrid.rowList.toArray()[0].data.dimensionValues.get('ProductCategory')).toBe('Bikes');
26212621
});
2622+
2623+
it('should allow setting aggregatorName instead of aggregator.', () => {
2624+
const pivotGrid = fixture.componentInstance.pivotGrid;
2625+
pivotGrid.pivotConfiguration.values = [
2626+
{
2627+
member: 'UnitsSold',
2628+
aggregate: {
2629+
aggregatorName: 'SUM',
2630+
key: 'SUM',
2631+
label: 'Sum',
2632+
},
2633+
enabled: true
2634+
}
2635+
];
2636+
pivotGrid.notifyDimensionChange(true);
2637+
fixture.detectChanges();
2638+
let pivotRecord = (pivotGrid.rowList.first as IgxPivotRowComponent).data;
2639+
expect(pivotRecord.aggregationValues.get('US')).toBe(296);
2640+
expect(pivotRecord.aggregationValues.get('Bulgaria')).toBe(774);
2641+
expect(pivotRecord.aggregationValues.get('UK')).toBe(293);
2642+
expect(pivotRecord.aggregationValues.get('Japan')).toBe(240);
2643+
});
2644+
2645+
it('should use aggregatorName if both aggregatorName and aggregator are set at the same time.', () => {
2646+
const pivotGrid = fixture.componentInstance.pivotGrid;
2647+
pivotGrid.pivotConfiguration.values = [
2648+
{
2649+
member: 'UnitsSold',
2650+
aggregate: {
2651+
aggregatorName: 'SUM',
2652+
aggregator: IgxPivotNumericAggregate.average,
2653+
key: 'SUM',
2654+
label: 'Sum',
2655+
},
2656+
enabled: true
2657+
}
2658+
];
2659+
pivotGrid.notifyDimensionChange(true);
2660+
fixture.detectChanges();
2661+
let pivotRecord = (pivotGrid.rowList.first as IgxPivotRowComponent).data;
2662+
expect(pivotRecord.aggregationValues.get('US')).toBe(296);
2663+
expect(pivotRecord.aggregationValues.get('Bulgaria')).toBe(774);
2664+
expect(pivotRecord.aggregationValues.get('UK')).toBe(293);
2665+
expect(pivotRecord.aggregationValues.get('Japan')).toBe(240);
2666+
});
26222667
});
26232668
});

0 commit comments

Comments
 (0)