Skip to content

Commit 3fd96c1

Browse files
committed
fix(pivotGrid): Fix pivot dimension invalid inject and pivot grid init in tests.
1 parent 2a63192 commit 3fd96c1

File tree

2 files changed

+39
-41
lines changed

2 files changed

+39
-41
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class IgxPivotDateDimension implements IPivotDimension {
7878
}
7979

8080
public get resourceStrings(): IGridResourceStrings {
81-
return this._resourceStrings || this._defaultResourceStrings;
81+
return this._resourceStrings || getCurrentResourceStrings(GridResourceStringsEN, false);
8282
}
8383

8484
/**
@@ -112,11 +112,8 @@ export class IgxPivotDateDimension implements IPivotDimension {
112112
public memberName = 'AllPeriods';
113113
public displayName: string;
114114
private _resourceStrings: IGridResourceStrings = null;
115-
private _defaultResourceStrings = getCurrentResourceStrings(GridResourceStringsEN);
116115
private _baseDimension: IPivotDimension;
117116
private _options: IPivotDateDimensionOptions = {};
118-
private _destroyRef = inject(DestroyRef);
119-
120117

121118
/**
122119
* Creates additional pivot date dimensions based on a provided dimension describing date data:
@@ -135,9 +132,6 @@ export class IgxPivotDateDimension implements IPivotDimension {
135132
if (this.baseDimension && this.options) {
136133
this.initialize(this.baseDimension, this.options);
137134
}
138-
onResourceChangeHandle(this._destroyRef, () => {
139-
this._defaultResourceStrings = getCurrentResourceStrings(GridResourceStringsEN, false);
140-
}, this);
141135
}
142136

143137
protected initialize(inBaseDimension, inOptions) {

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

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { setElementSize } from '../../test-utils/helper-utils.spec';
2323
import { IgxPivotRowDimensionMrlRowComponent } from './pivot-row-dimension-mrl-row.component';
2424
import { IgxPivotRowDimensionContentComponent } from './pivot-row-dimension-content.component';
2525
import { IgxGridCellComponent } from '../cell.component';
26+
import { getI18nManager } from 'igniteui-i18n-core';
2627

2728
const CSS_CLASS_LIST = 'igx-drop-down__list';
2829
const CSS_CLASS_ITEM = 'igx-drop-down__item';
@@ -45,8 +46,10 @@ describe('IgxPivotGrid #pivotGrid', () => {
4546
let fixture: ComponentFixture<IgxPivotGridTestBaseComponent>;
4647

4748
beforeEach(waitForAsync(() => {
49+
getI18nManager().toggleEvents(false);
4850
fixture = TestBed.createComponent(IgxPivotGridTestBaseComponent);
4951
fixture.detectChanges();
52+
getI18nManager().toggleEvents(true);
5053
}));
5154

5255
it('should show empty template when there are no dimensions and values', () => {
@@ -316,9 +319,10 @@ describe('IgxPivotGrid #pivotGrid', () => {
316319
{
317320
memberName: 'Date',
318321
enabled: true
319-
}, {
320-
total: false
321-
}
322+
},
323+
{
324+
total: false
325+
}
322326
);
323327
pivotGrid.notifyDimensionChange(true);
324328
expect(pivotGrid.columns.length).toBe(5);
@@ -760,7 +764,7 @@ describe('IgxPivotGrid #pivotGrid', () => {
760764
expect(pivotGrid.columns.length).toBe(3);
761765
});
762766

763-
it('should calculate row headers according to grid size', async() => {
767+
it('should calculate row headers according to grid size', async () => {
764768
const pivotGrid = fixture.componentInstance.pivotGrid;
765769
const rowHeightSmall = 32;
766770
const rowHeightMedium = 40;
@@ -797,7 +801,7 @@ describe('IgxPivotGrid #pivotGrid', () => {
797801
expect(rowHeader[0].nativeElement.offsetHeight).toBe(rowHeightMedium);
798802
});
799803

800-
it('should render with correct width when set to 100% inside of flex container', async() => {
804+
it('should render with correct width when set to 100% inside of flex container', async () => {
801805
fixture = TestBed.createComponent(IgxPivotGridFlexContainerComponent);
802806
fixture.detectChanges();
803807
await wait(100);
@@ -2119,7 +2123,7 @@ describe('IgxPivotGrid #pivotGrid', () => {
21192123
cell.nativeElement.click();
21202124
const cellClickargs: IGridCellEventArgs = { cell, event: new MouseEvent('click') };
21212125

2122-
const gridCell = cellClickargs.cell as IgxGridCellComponent;
2126+
const gridCell = cellClickargs.cell as IgxGridCellComponent;
21232127
const firstEntry = gridCell.rowData.aggregationValues.entries().next().value;
21242128
expect(firstEntry).toEqual(['USA-UnitsSold', 829]);
21252129
});
@@ -2233,38 +2237,38 @@ describe('IgxPivotGrid #pivotGrid', () => {
22332237
columns: fixture.componentInstance.pivotConfigHierarchy.columns,
22342238
rows: fixture.componentInstance.pivotConfigHierarchy.rows,
22352239
values: [
2236-
{
2237-
member: 'UnitsSold',
2238-
aggregate: {
2239-
aggregator: IgxPivotNumericAggregate.sum,
2240-
key: 'SUM',
2241-
label: 'Sum'
2242-
},
2243-
enabled: true,
2244-
formatter: (value, row, column) => {
2245-
if (!column || !column.value || column.value.member !== 'UnitsSold') {
2246-
correctFirstColumnData = false;
2240+
{
2241+
member: 'UnitsSold',
2242+
aggregate: {
2243+
aggregator: IgxPivotNumericAggregate.sum,
2244+
key: 'SUM',
2245+
label: 'Sum'
2246+
},
2247+
enabled: true,
2248+
formatter: (value, row, column) => {
2249+
if (!column || !column.value || column.value.member !== 'UnitsSold') {
2250+
correctFirstColumnData = false;
2251+
}
2252+
return value;
22472253
}
2248-
return value;
2249-
}
2250-
},
2251-
{
2252-
member: 'AmountOfSale',
2253-
displayName: 'Amount of Sale',
2254-
aggregate: {
2255-
aggregator: IgxTotalSaleAggregate.totalSale,
2256-
key: 'TOTAL',
2257-
label: 'Total'
22582254
},
2259-
enabled: true,
2260-
formatter: (value, row, column) => {
2261-
if (!column || !column.value || column.value.member !== 'AmountOfSale') {
2262-
correctSecondColumnData = false;
2255+
{
2256+
member: 'AmountOfSale',
2257+
displayName: 'Amount of Sale',
2258+
aggregate: {
2259+
aggregator: IgxTotalSaleAggregate.totalSale,
2260+
key: 'TOTAL',
2261+
label: 'Total'
2262+
},
2263+
enabled: true,
2264+
formatter: (value, row, column) => {
2265+
if (!column || !column.value || column.value.member !== 'AmountOfSale') {
2266+
correctSecondColumnData = false;
2267+
}
2268+
return value;
22632269
}
2264-
return value;
22652270
}
2266-
}
2267-
]
2271+
]
22682272
};
22692273

22702274
pivotGrid.width = '1500px';

0 commit comments

Comments
 (0)