@@ -2,6 +2,7 @@ import { fakeAsync, TestBed } from '@angular/core/testing';
22import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
33import { IgxPivotGridModule } from 'igniteui-angular' ;
44import { configureTestSuite } from '../../test-utils/configure-suite' ;
5+ import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
56import { IgxPivotGridTestBaseComponent } from '../../test-utils/pivot-grid-samples.spec' ;
67
78describe ( 'Basic IgxPivotGrid #pivotGrid' , ( ) => {
@@ -37,4 +38,85 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
3738 expect ( cells . first . nativeElement . classList ) . toContain ( 'test' ) ;
3839 expect ( cells . last . nativeElement . classList ) . not . toContain ( 'test' ) ;
3940 } ) ;
41+ describe ( 'IgxPivotGrid Features #pivotGrid' , ( ) => {
42+ it ( 'should show excel style filtering via dimension chip.' , ( ) => {
43+ const excelMenu = GridFunctions . getExcelStyleFilteringComponent ( fixture , 'igx-pivot-grid' ) ;
44+ const headerRow = fixture . nativeElement . querySelector ( 'igx-pivot-header-row' ) ;
45+ const rowChip = headerRow . querySelector ( 'igx-chip[id="All"]' ) ;
46+ const filterIcon = rowChip . querySelectorAll ( 'igx-icon' ) [ 2 ] ;
47+
48+ expect ( excelMenu . parentElement . parentElement . attributes . hidden ) . not . toBeUndefined ( ) ;
49+ filterIcon . click ( ) ;
50+ fixture . detectChanges ( ) ;
51+ const esfSearch = GridFunctions . getExcelFilteringSearchComponent ( fixture , excelMenu , 'igx-pivot-grid' ) ;
52+ const checkBoxes = esfSearch . querySelectorAll ( 'igx-checkbox' ) ;
53+ // should show and should display correct checkboxes.
54+ expect ( excelMenu . parentElement . parentElement . attributes . hidden ) . toBeUndefined ( ) ;
55+ expect ( ( checkBoxes [ 0 ] . querySelector ( '.igx-checkbox__label' ) as HTMLElement ) . innerText ) . toEqual ( 'Select All' ) ;
56+ expect ( ( checkBoxes [ 1 ] . querySelector ( '.igx-checkbox__label' ) as HTMLElement ) . innerText ) . toEqual ( 'Accessories' ) ;
57+ expect ( ( checkBoxes [ 2 ] . querySelector ( '.igx-checkbox__label' ) as HTMLElement ) . innerText ) . toEqual ( 'Bikes' ) ;
58+ expect ( ( checkBoxes [ 3 ] . querySelector ( '.igx-checkbox__label' ) as HTMLElement ) . innerText ) . toEqual ( 'Clothing' ) ;
59+ expect ( ( checkBoxes [ 4 ] . querySelector ( '.igx-checkbox__label' ) as HTMLElement ) . innerText ) . toEqual ( 'Components' ) ;
60+ } ) ;
61+
62+ it ( 'should filter rows via excel style filtering dimension chip.' , ( ) => {
63+ const pivotGrid = fixture . componentInstance . pivotGrid ;
64+ const headerRow = fixture . nativeElement . querySelector ( 'igx-pivot-header-row' ) ;
65+ const rowChip = headerRow . querySelector ( 'igx-chip[id="All"]' ) ;
66+ const filterIcon = rowChip . querySelectorAll ( 'igx-icon' ) [ 2 ] ;
67+ filterIcon . click ( ) ;
68+ fixture . detectChanges ( ) ;
69+
70+ const excelMenu = GridFunctions . getExcelStyleFilteringComponent ( fixture , 'igx-pivot-grid' ) ;
71+ const checkboxes : any [ ] = Array . from ( GridFunctions . getExcelStyleFilteringCheckboxes ( fixture , excelMenu , 'igx-pivot-grid' ) ) ;
72+
73+ // uncheck Accessories
74+ checkboxes [ 1 ] . click ( ) ;
75+ fixture . detectChanges ( ) ;
76+
77+ // uncheck Bikes
78+ checkboxes [ 2 ] . click ( ) ;
79+ fixture . detectChanges ( ) ;
80+
81+ // Click 'apply' button to apply filter.
82+ GridFunctions . clickApplyExcelStyleFiltering ( fixture , excelMenu , 'igx-pivot-grid' ) ;
83+ fixture . detectChanges ( ) ;
84+
85+ // check rows
86+ const rows = pivotGrid . rowList . toArray ( ) ;
87+ expect ( rows . length ) . toBe ( 3 ) ;
88+ const expectedHeaders = [ 'All' , 'Clothing' , 'Components' ] ;
89+ const rowDimensionHeaders = rows . map ( x => x . rowDimension ) . flat ( ) . map ( x => x . header ) ;
90+ expect ( rowDimensionHeaders ) . toEqual ( expectedHeaders ) ;
91+ } ) ;
92+
93+ it ( 'should filter columns via excel style filtering dimension chip.' , ( ) => {
94+ const pivotGrid = fixture . componentInstance . pivotGrid ;
95+ const headerRow = fixture . nativeElement . querySelector ( 'igx-pivot-header-row' ) ;
96+ const rowChip = headerRow . querySelector ( 'igx-chip[id="Country"]' ) ;
97+ const filterIcon = rowChip . querySelectorAll ( 'igx-icon' ) [ 2 ] ;
98+ filterIcon . click ( ) ;
99+ fixture . detectChanges ( ) ;
100+ const excelMenu = GridFunctions . getExcelStyleFilteringComponent ( fixture , 'igx-pivot-grid' ) ;
101+ const checkboxes : any [ ] = Array . from ( GridFunctions . getExcelStyleFilteringCheckboxes ( fixture , excelMenu , 'igx-pivot-grid' ) ) ;
102+
103+ // uncheck Bulgaria
104+ checkboxes [ 1 ] . click ( ) ;
105+ fixture . detectChanges ( ) ;
106+
107+ // uncheck Uruguay
108+ checkboxes [ 2 ] . click ( ) ;
109+ fixture . detectChanges ( ) ;
110+
111+
112+ // Click 'apply' button to apply filter.
113+ GridFunctions . clickApplyExcelStyleFiltering ( fixture , excelMenu , 'igx-pivot-grid' ) ;
114+ fixture . detectChanges ( ) ;
115+
116+ // check columns
117+ const colHeaders = pivotGrid . columns . filter ( x => x . level === 0 ) . map ( x => x . header ) ;
118+ const expected = [ 'USA' ] ;
119+ expect ( colHeaders ) . toEqual ( expected ) ;
120+ } ) ;
121+ } ) ;
40122} ) ;
0 commit comments