|
1 | 1 | import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
2 | 2 | import { By } from '@angular/platform-browser';
|
3 | 3 | import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
4 |
| -import { FilteringExpressionsTree, FilteringLogic, IgxPivotGridComponent, IgxPivotRowDimensionHeaderGroupComponent, IgxStringFilteringOperand } from 'igniteui-angular'; |
| 4 | +import { FilteringExpressionsTree, FilteringLogic, GridColumnDataType, IgxPivotGridComponent, IgxPivotRowDimensionHeaderGroupComponent, IgxStringFilteringOperand } from 'igniteui-angular'; |
5 | 5 | import { IgxChipComponent } from '../../chips/chip.component';
|
6 | 6 | import { IgxChipsAreaComponent } from '../../chips/chips-area.component';
|
7 | 7 | import { DefaultPivotSortingStrategy } from '../../data-operations/pivot-sort-strategy';
|
@@ -1130,6 +1130,51 @@ describe('IgxPivotGrid #pivotGrid', () => {
|
1130 | 1130 | expect(pivotGrid.dimensionsSortingExpressions).toEqual(expectedExpressions);
|
1131 | 1131 | });
|
1132 | 1132 |
|
| 1133 | + it('should apply correct sorting for IgxPivotDateDimension', () => { |
| 1134 | + const pivotGrid = fixture.componentInstance.pivotGrid; |
| 1135 | + |
| 1136 | + pivotGrid.pivotConfiguration.columns = [ |
| 1137 | + new IgxPivotDateDimension( |
| 1138 | + { |
| 1139 | + memberName: 'Date', |
| 1140 | + memberFunction: (data) => { |
| 1141 | + return data['Date']; |
| 1142 | + }, |
| 1143 | + enabled: true, |
| 1144 | + dataType: GridColumnDataType.Date |
| 1145 | + }, |
| 1146 | + { |
| 1147 | + total: false, |
| 1148 | + years: false, |
| 1149 | + quarters: false, |
| 1150 | + months: false, |
| 1151 | + fullDate: true |
| 1152 | + } |
| 1153 | + ) |
| 1154 | + ]; |
| 1155 | + pivotGrid.notifyDimensionChange(true); |
| 1156 | + fixture.detectChanges(); |
| 1157 | + |
| 1158 | + const headerRow = fixture.nativeElement.querySelector('igx-pivot-header-row'); |
| 1159 | + const colChip = headerRow.querySelector('igx-chip[id="Date"]'); |
| 1160 | + |
| 1161 | + //sort asc |
| 1162 | + colChip.click(); |
| 1163 | + fixture.detectChanges(); |
| 1164 | + |
| 1165 | + let colHeaders = pivotGrid.columns.filter(x => x.level === 0).map(x => x.header); |
| 1166 | + let expected = ['01/05/2019', '01/06/2020', '02/19/2020', '05/12/2020', '01/01/2021', '04/07/2021', '12/08/2021'] |
| 1167 | + expect(colHeaders).toEqual(expected); |
| 1168 | + |
| 1169 | + // sort desc |
| 1170 | + colChip.click(); |
| 1171 | + fixture.detectChanges(); |
| 1172 | + |
| 1173 | + colHeaders = pivotGrid.columns.filter(x => x.level === 0).map(x => x.header); |
| 1174 | + expected = ['12/08/2021', '04/07/2021', '01/01/2021', '05/12/2020', '02/19/2020', '01/06/2020', '01/05/2019']; |
| 1175 | + expect(colHeaders).toEqual(expected); |
| 1176 | + }); |
| 1177 | + |
1133 | 1178 | it('should sort on column for single row dimension.', () => {
|
1134 | 1179 | const pivotGrid = fixture.componentInstance.pivotGrid;
|
1135 | 1180 | let headerCell = GridFunctions.getColumnHeader('USA-UnitsSold', fixture);
|
|
0 commit comments