|
1 | 1 | import { fakeAsync, TestBed } from '@angular/core/testing';
|
2 | 2 | import { By } from '@angular/platform-browser';
|
3 | 3 | import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
4 |
| -import { IgxPivotGridModule } from 'igniteui-angular'; |
| 4 | +import { IgxPivotDateDimension, IgxPivotGridModule } from 'igniteui-angular'; |
5 | 5 | import { configureTestSuite } from '../../test-utils/configure-suite';
|
6 | 6 | import { GridFunctions, GridSelectionFunctions } from '../../test-utils/grid-functions.spec';
|
7 | 7 | import { IgxPivotGridTestBaseComponent, IgxPivotGridTestComplexHierarchyComponent, IgxTotalSaleAggregate } from '../../test-utils/pivot-grid-samples.spec';
|
@@ -106,6 +106,75 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
|
106 | 106 | expect(pivotGrid.columns.length).not.toBe(9);
|
107 | 107 | });
|
108 | 108 |
|
| 109 | + it('should collapse column with 1 value dimension', () => { |
| 110 | + const pivotGrid = fixture.componentInstance.pivotGrid; |
| 111 | + pivotGrid.pivotConfiguration.values.pop(); |
| 112 | + pivotGrid.pivotConfiguration.columns = [{ |
| 113 | + memberName: 'AllCountries', |
| 114 | + memberFunction: () => 'All Countries', |
| 115 | + enabled: true, |
| 116 | + childLevel: { |
| 117 | + memberName: 'Country', |
| 118 | + enabled: true |
| 119 | + } |
| 120 | + }]; |
| 121 | + pivotGrid.pivotConfiguration.rows[0] = new IgxPivotDateDimension( |
| 122 | + { |
| 123 | + memberName: 'Date', |
| 124 | + enabled: true |
| 125 | + }, { |
| 126 | + total: false |
| 127 | + } |
| 128 | + ); |
| 129 | + pivotGrid.notifyDimensionChange(true); |
| 130 | + expect(pivotGrid.columns.length).toBe(5); |
| 131 | + expect(pivotGrid.columnGroupStates.size).toBe(0); |
| 132 | + const headerRow = fixture.nativeElement.querySelector('igx-pivot-header-row'); |
| 133 | + const header = headerRow.querySelector('igx-grid-header-group'); |
| 134 | + const expander = header.querySelectorAll('igx-icon')[0]; |
| 135 | + expander.click(); |
| 136 | + fixture.detectChanges(); |
| 137 | + expect(pivotGrid.columnGroupStates.size).toBe(1); |
| 138 | + const value = pivotGrid.columnGroupStates.entries().next().value; |
| 139 | + expect(value[0]).toEqual('All Countries'); |
| 140 | + expect(value[1]).toBeTrue(); |
| 141 | + }); |
| 142 | + |
| 143 | + it('should collapse column with 2 value dimension', () => { |
| 144 | + const pivotGrid = fixture.componentInstance.pivotGrid; |
| 145 | + pivotGrid.pivotConfiguration.columns = [{ |
| 146 | + memberName: 'AllCountries', |
| 147 | + memberFunction: () => 'All Countries', |
| 148 | + enabled: true, |
| 149 | + childLevel: { |
| 150 | + memberName: 'Country', |
| 151 | + enabled: true |
| 152 | + } |
| 153 | + }, |
| 154 | + { |
| 155 | + memberName: 'SellerName', |
| 156 | + enabled: true |
| 157 | + }]; |
| 158 | + pivotGrid.notifyDimensionChange(true); |
| 159 | + fixture.detectChanges(); |
| 160 | + expect(pivotGrid.columnGroupStates.size).toBe(0); |
| 161 | + const headerRow = fixture.nativeElement.querySelector('igx-pivot-header-row'); |
| 162 | + const header = headerRow.querySelector('igx-grid-header-group'); |
| 163 | + const expander = header.querySelectorAll('igx-icon')[0]; |
| 164 | + expander.click(); |
| 165 | + fixture.detectChanges(); |
| 166 | + expect(pivotGrid.columnGroupStates.size).toBe(1); |
| 167 | + let value = pivotGrid.columnGroupStates.entries().next().value; |
| 168 | + expect(value[0]).toEqual('All Countries'); |
| 169 | + expect(value[1]).toBeTrue(); |
| 170 | + |
| 171 | + expander.click(); |
| 172 | + fixture.detectChanges(); |
| 173 | + value = pivotGrid.columnGroupStates.entries().next().value; |
| 174 | + expect(value[0]).toEqual('All Countries'); |
| 175 | + expect(value[1]).toBeFalse(); |
| 176 | + }); |
| 177 | + |
109 | 178 | describe('IgxPivotGrid Features #pivotGrid', () => {
|
110 | 179 | it('should show excel style filtering via dimension chip.', () => {
|
111 | 180 | const excelMenu = GridFunctions.getExcelStyleFilteringComponent(fixture, 'igx-pivot-grid');
|
|
0 commit comments