|
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, IgxPivotRowDimensionContentComponent, 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';
|
@@ -965,3 +965,110 @@ describe('IgxPivotGrid complex hierarchy #pivotGrid', () => {
|
965 | 965 | GridSelectionFunctions.verifyColumnGroupSelected(fixture, group, false);
|
966 | 966 | });
|
967 | 967 | });
|
| 968 | + |
| 969 | +describe('IgxPivotGrid Resizing #pivotGrid', () => { |
| 970 | + let fixture: ComponentFixture<any>; |
| 971 | + let pivotGrid: IgxPivotGridComponent; |
| 972 | + |
| 973 | + configureTestSuite((() => { |
| 974 | + TestBed.configureTestingModule({ |
| 975 | + declarations: [ |
| 976 | + IgxPivotGridTestComplexHierarchyComponent |
| 977 | + ], |
| 978 | + imports: [ |
| 979 | + NoopAnimationsModule, |
| 980 | + IgxPivotGridModule |
| 981 | + ] |
| 982 | + }); |
| 983 | + })); |
| 984 | + |
| 985 | + beforeEach(fakeAsync(() => { |
| 986 | + fixture = TestBed.createComponent(IgxPivotGridTestComplexHierarchyComponent); |
| 987 | + fixture.detectChanges(); |
| 988 | + |
| 989 | + pivotGrid = fixture.componentInstance.pivotGrid; |
| 990 | + })); |
| 991 | + |
| 992 | + it('should define grid with resizable columns.', fakeAsync(() => { |
| 993 | + let dimensionContents = fixture.debugElement.queryAll(By.css('.igx-grid__tbody-pivot-dimension')); |
| 994 | + |
| 995 | + let rowHeaders = dimensionContents[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 996 | + expect(rowHeaders[0].componentInstance.column.resizable).toBeTrue(); |
| 997 | + expect(rowHeaders[3].componentInstance.column.resizable).toBeTrue(); |
| 998 | + |
| 999 | + rowHeaders = dimensionContents[1].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1000 | + expect(rowHeaders[0].componentInstance.column.resizable).toBeTrue(); |
| 1001 | + expect(rowHeaders[1].componentInstance.column.resizable).toBeTrue(); |
| 1002 | + expect(rowHeaders[5].componentInstance.column.resizable).toBeTrue(); |
| 1003 | + expect(rowHeaders[7].componentInstance.column.resizable).toBeTrue(); |
| 1004 | + })); |
| 1005 | + |
| 1006 | + it('should update grid after resizing a top dimension header to be bigger.', fakeAsync(() => { |
| 1007 | + let dimensionContents = fixture.debugElement.queryAll(By.css('.igx-grid__tbody-pivot-dimension')); |
| 1008 | + |
| 1009 | + let rowHeaders = dimensionContents[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1010 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('200px'); |
| 1011 | + expect(rowHeaders[3].componentInstance.column.width).toEqual('200px'); |
| 1012 | + |
| 1013 | + rowHeaders = dimensionContents[1].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1014 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('200px'); |
| 1015 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1016 | + expect(rowHeaders[5].componentInstance.column.width).toEqual('200px'); |
| 1017 | + expect(rowHeaders[7].componentInstance.column.width).toEqual('200px'); |
| 1018 | + |
| 1019 | + rowHeaders = dimensionContents[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1020 | + const headerResArea = GridFunctions.getHeaderResizeArea(rowHeaders[0]).nativeElement; |
| 1021 | + |
| 1022 | + // Resize first column |
| 1023 | + UIInteractions.simulateMouseEvent('mousedown', headerResArea, 100, 0); |
| 1024 | + tick(200); |
| 1025 | + fixture.detectChanges(); |
| 1026 | + |
| 1027 | + const resizer = GridFunctions.getResizer(fixture).nativeElement; |
| 1028 | + expect(resizer).toBeDefined(); |
| 1029 | + UIInteractions.simulateMouseEvent('mousemove', resizer, 300, 5); |
| 1030 | + UIInteractions.simulateMouseEvent('mouseup', resizer, 300, 5); |
| 1031 | + fixture.detectChanges(); |
| 1032 | + |
| 1033 | + rowHeaders = dimensionContents[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1034 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1035 | + expect(rowHeaders[3].componentInstance.column.width).toEqual('400px'); |
| 1036 | + |
| 1037 | + rowHeaders = dimensionContents[1].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1038 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('200px'); |
| 1039 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1040 | + expect(rowHeaders[5].componentInstance.column.width).toEqual('200px'); |
| 1041 | + expect(rowHeaders[7].componentInstance.column.width).toEqual('200px'); |
| 1042 | + })); |
| 1043 | + |
| 1044 | + it('should update grid after resizing a child dimension header to be bigger.', fakeAsync(() => { |
| 1045 | + let dimensionContents = fixture.debugElement.queryAll(By.css('.igx-grid__tbody-pivot-dimension')); |
| 1046 | + |
| 1047 | + let rowHeaders = dimensionContents[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1048 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('200px'); |
| 1049 | + expect(rowHeaders[3].componentInstance.column.width).toEqual('200px'); |
| 1050 | + |
| 1051 | + const headerResArea = GridFunctions.getHeaderResizeArea(rowHeaders[3]).nativeElement; |
| 1052 | + |
| 1053 | + // Resize first column |
| 1054 | + UIInteractions.simulateMouseEvent('mousedown', headerResArea, 100, 0); |
| 1055 | + tick(200); |
| 1056 | + fixture.detectChanges(); |
| 1057 | + |
| 1058 | + const resizer = GridFunctions.getResizer(fixture).nativeElement; |
| 1059 | + expect(resizer).toBeDefined(); |
| 1060 | + UIInteractions.simulateMouseEvent('mousemove', resizer, 300, 5); |
| 1061 | + UIInteractions.simulateMouseEvent('mouseup', resizer, 300, 5); |
| 1062 | + fixture.detectChanges(); |
| 1063 | + |
| 1064 | + rowHeaders = dimensionContents[0].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1065 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('400px'); |
| 1066 | + expect(rowHeaders[3].componentInstance.column.width).toEqual('400px'); |
| 1067 | + |
| 1068 | + rowHeaders = dimensionContents[1].queryAll(By.directive(IgxPivotRowDimensionHeaderGroupComponent)); |
| 1069 | + expect(rowHeaders[0].componentInstance.column.width).toEqual('200px'); |
| 1070 | + expect(rowHeaders[1].componentInstance.column.width).toEqual('200px'); |
| 1071 | + expect(rowHeaders[5].componentInstance.column.width).toEqual('200px'); |
| 1072 | + expect(rowHeaders[7].componentInstance.column.width).toEqual('200px'); |
| 1073 | + })); |
| 1074 | +}); |
0 commit comments