|
1 |
| -import { fakeAsync, TestBed } from '@angular/core/testing'; |
| 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, IgxPivotDateDimension, IgxPivotGridModule, IgxStringFilteringOperand } from 'igniteui-angular'; |
| 4 | +import { FilteringExpressionsTree, FilteringLogic, IgxPivotDateDimension, IgxPivotGridComponent, IgxPivotGridModule, IgxPivotRowComponent, IgxPivotRowDimensionHeaderGroupComponent, IgxStringFilteringOperand } from 'igniteui-angular'; |
5 | 5 | import { IgxChipsAreaComponent } from '../../chips/chips-area.component';
|
6 | 6 | import { configureTestSuite } from '../../test-utils/configure-suite';
|
7 | 7 | import { GridFunctions, GridSelectionFunctions } from '../../test-utils/grid-functions.spec';
|
@@ -941,3 +941,110 @@ describe('IgxPivotGrid complex hierarchy #pivotGrid', () => {
|
941 | 941 | GridSelectionFunctions.verifyColumnGroupSelected(fixture, group, false);
|
942 | 942 | });
|
943 | 943 | });
|
| 944 | + |
| 945 | +describe('IgxPivotGrid Resizing #pivotGrid', () => { |
| 946 | + let fixture: ComponentFixture<any>; |
| 947 | + let pivotGrid: IgxPivotGridComponent; |
| 948 | + |
| 949 | + configureTestSuite((() => { |
| 950 | + TestBed.configureTestingModule({ |
| 951 | + declarations: [ |
| 952 | + IgxPivotGridTestComplexHierarchyComponent |
| 953 | + ], |
| 954 | + imports: [ |
| 955 | + NoopAnimationsModule, |
| 956 | + IgxPivotGridModule |
| 957 | + ] |
| 958 | + }); |
| 959 | + })); |
| 960 | + |
| 961 | + beforeEach(fakeAsync(() => { |
| 962 | + fixture = TestBed.createComponent(IgxPivotGridTestComplexHierarchyComponent); |
| 963 | + fixture.detectChanges(); |
| 964 | + |
| 965 | + pivotGrid = fixture.componentInstance.pivotGrid; |
| 966 | + })); |
| 967 | + |
| 968 | + it('should define grid with resizable columns.', fakeAsync(() => { |
| 969 | + let pivotRows = fixture.debugElement.queryAll(By.directive(IgxPivotRowComponent)); |
| 970 | + |
| 971 | + let rowHeaders = pivotRows[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 972 | + expect(rowHeaders.length).toEqual(2); |
| 973 | + expect(rowHeaders[0].componentInstance.column.resizable).toBeTrue(); |
| 974 | + expect(rowHeaders[1].componentInstance.column.resizable).toBeTrue(); |
| 975 | + |
| 976 | + rowHeaders = pivotRows[3].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 977 | + expect(rowHeaders[0].componentInstance.column.resizable).toBeTrue(); |
| 978 | + expect(rowHeaders[1].componentInstance.column.resizable).toBeTrue(); |
| 979 | + |
| 980 | + rowHeaders = pivotRows[7].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 981 | + expect(rowHeaders[0].componentInstance.column.resizable).toBeTrue(); |
| 982 | + expect(rowHeaders[1].componentInstance.column.resizable).toBeTrue(); |
| 983 | + })); |
| 984 | + |
| 985 | + it('should update grid after resizing a top dimension header to be bigger.', fakeAsync(() => { |
| 986 | + let pivotRows = fixture.debugElement.queryAll(By.directive(IgxPivotRowComponent)); |
| 987 | + |
| 988 | + let rowHeaders = pivotRows[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 989 | + expect(rowHeaders.length).toEqual(2); |
| 990 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('200px'); |
| 991 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 992 | + |
| 993 | + const headerResArea = GridFunctions.getHeaderResizeArea(rowHeaders[0]).nativeElement; |
| 994 | + |
| 995 | + // Resize first column |
| 996 | + UIInteractions.simulateMouseEvent('mousedown', headerResArea, 100, 0); |
| 997 | + tick(200); |
| 998 | + fixture.detectChanges(); |
| 999 | + |
| 1000 | + const resizer = GridFunctions.getResizer(fixture).nativeElement; |
| 1001 | + expect(resizer).toBeDefined(); |
| 1002 | + UIInteractions.simulateMouseEvent('mousemove', resizer, 300, 5); |
| 1003 | + UIInteractions.simulateMouseEvent('mouseup', resizer, 300, 5); |
| 1004 | + fixture.detectChanges(); |
| 1005 | + |
| 1006 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1007 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1008 | + |
| 1009 | + rowHeaders = pivotRows[3].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1010 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1011 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1012 | + |
| 1013 | + rowHeaders = pivotRows[7].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1014 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1015 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1016 | + })); |
| 1017 | + |
| 1018 | + it('should update grid after resizing a child dimension header to be bigger.', fakeAsync(() => { |
| 1019 | + let pivotRows = fixture.debugElement.queryAll(By.directive(IgxPivotRowComponent)); |
| 1020 | + |
| 1021 | + let rowHeaders = pivotRows[7].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1022 | + expect(rowHeaders.length).toEqual(2); |
| 1023 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('200px'); |
| 1024 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1025 | + |
| 1026 | + const headerResArea = GridFunctions.getHeaderResizeArea(rowHeaders[0]).nativeElement; |
| 1027 | + |
| 1028 | + // Resize first column |
| 1029 | + UIInteractions.simulateMouseEvent('mousedown', headerResArea, 100, 0); |
| 1030 | + tick(200); |
| 1031 | + fixture.detectChanges(); |
| 1032 | + |
| 1033 | + const resizer = GridFunctions.getResizer(fixture).nativeElement; |
| 1034 | + expect(resizer).toBeDefined(); |
| 1035 | + UIInteractions.simulateMouseEvent('mousemove', resizer, 300, 5); |
| 1036 | + UIInteractions.simulateMouseEvent('mouseup', resizer, 300, 5); |
| 1037 | + fixture.detectChanges(); |
| 1038 | + |
| 1039 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1040 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1041 | + |
| 1042 | + rowHeaders = pivotRows[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1043 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1044 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1045 | + |
| 1046 | + rowHeaders = pivotRows[3].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1047 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1048 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1049 | + })); |
| 1050 | +}); |
0 commit comments