@@ -37,4 +37,48 @@ describe('Basic IgxPivotGrid #pivotGrid', () => {
37
37
expect ( cells . first . nativeElement . classList ) . toContain ( 'test' ) ;
38
38
expect ( cells . last . nativeElement . classList ) . not . toContain ( 'test' ) ;
39
39
} ) ;
40
+
41
+ describe ( 'IgxPivotGrid Features #pivotGrid' , ( ) => {
42
+ it ( 'should apply sorting for dimension via row chip' , ( ) => {
43
+ fixture . detectChanges ( ) ;
44
+ const pivotGrid = fixture . componentInstance . pivotGrid ;
45
+ const headerRow = fixture . nativeElement . querySelector ( 'igx-pivot-header-row' ) ;
46
+ const rowChip = headerRow . querySelector ( 'igx-chip[id="All"]' ) ;
47
+ rowChip . click ( ) ;
48
+ fixture . detectChanges ( ) ;
49
+ let rows = pivotGrid . rowList . toArray ( ) ;
50
+ let expectedOrder = [ 'All' , 'Accessories' , 'Bikes' , 'Clothing' , 'Components' ] ;
51
+ let rowDimensionHeaders = rows . map ( x => x . rowDimension ) . flat ( ) . map ( x => x . header ) ;
52
+ expect ( rowDimensionHeaders ) . toEqual ( expectedOrder ) ;
53
+
54
+ rowChip . click ( ) ;
55
+ fixture . detectChanges ( ) ;
56
+ rows = pivotGrid . rowList . toArray ( ) ;
57
+ expectedOrder = [ 'All' , 'Components' , 'Clothing' , 'Bikes' , 'Accessories' ] ;
58
+ rowDimensionHeaders = rows . map ( x => x . rowDimension ) . flat ( ) . map ( x => x . header ) ;
59
+ expect ( rowDimensionHeaders ) . toEqual ( expectedOrder ) ;
60
+ } ) ;
61
+
62
+ it ( 'should apply sorting for dimension via column chip' , ( ) => {
63
+ const pivotGrid = fixture . componentInstance . pivotGrid ;
64
+ const headerRow = fixture . nativeElement . querySelector ( 'igx-pivot-header-row' ) ;
65
+ const colChip = headerRow . querySelector ( 'igx-chip[id="Country"]' ) ;
66
+
67
+ // sort
68
+ colChip . click ( ) ;
69
+ fixture . detectChanges ( ) ;
70
+
71
+ let colHeaders = pivotGrid . columns . filter ( x => x . level === 0 ) . map ( x => x . header ) ;
72
+ let expected = [ 'Bulgaria' , 'USA' , 'Uruguay' ] ;
73
+ expect ( colHeaders ) . toEqual ( expected ) ;
74
+
75
+ // sort
76
+ colChip . click ( ) ;
77
+ fixture . detectChanges ( ) ;
78
+
79
+ colHeaders = pivotGrid . columns . filter ( x => x . level === 0 ) . map ( x => x . header ) ;
80
+ expected = [ 'Uruguay' , 'USA' , 'Bulgaria' ] ;
81
+ expect ( colHeaders ) . toEqual ( expected ) ;
82
+ } ) ;
83
+ } ) ;
40
84
} ) ;
0 commit comments