@@ -28,7 +28,7 @@ const GRID_COL_GROUP_THEAD_GROUP_CLASS = 'igx-grid-thead__group';
28
28
29
29
/* eslint-disable max-len */
30
30
describe ( 'IgxGrid - multi-column headers #grid' , ( ) => {
31
- let fixture ; let grid : IgxGridComponent ; let componentInstance ;
31
+ let fixture : ComponentFixture < any > ; let grid : IgxGridComponent ; let componentInstance ;
32
32
33
33
configureTestSuite ( ) ;
34
34
@@ -135,6 +135,45 @@ describe('IgxGrid - multi-column headers #grid', () => {
135
135
136
136
} ) ) ;
137
137
138
+ it ( 'Should render dynamic column group header correctly (#12165).' , ( ) => {
139
+ fixture = TestBed . createComponent ( BlueWhaleGridComponent ) as ComponentFixture < BlueWhaleGridComponent > ;
140
+ ( fixture as ComponentFixture < BlueWhaleGridComponent > ) . componentInstance . firstGroupRepeats = 1 ;
141
+ ( fixture as ComponentFixture < BlueWhaleGridComponent > ) . componentInstance . secondGroupRepeats = 1 ;
142
+ fixture . detectChanges ( ) ;
143
+
144
+ componentInstance = fixture . componentInstance ;
145
+ grid = componentInstance . grid ;
146
+ const columnWidthPx = parseInt ( componentInstance . columnWidth , 10 ) ;
147
+ // 2 levels of column group and 1 level of columns
148
+ const gridHeadersDepth = 3 ;
149
+
150
+ let firstGroupChildrenCount = 1 ;
151
+
152
+ let firstGroup = GridFunctions . getColumnGroupHeaders ( fixture ) [ 0 ] ;
153
+ testColumnGroupHeaderRendering ( firstGroup , firstGroupChildrenCount * columnWidthPx ,
154
+ gridHeadersDepth * grid . defaultRowHeight , componentInstance . firstGroupTitle ,
155
+ 'firstGroupColumn' , firstGroupChildrenCount ) ;
156
+
157
+ let allHeaders = GridFunctions . getColumnHeaders ( fixture ) . map < IgxGridHeaderComponent > ( x => x . componentInstance ) ;
158
+ let firstSixHeaders = allHeaders . slice ( 0 , 6 ) . map ( x => x . column . field ) ;
159
+ expect ( allHeaders . length ) . toEqual ( 14 ) ;
160
+ expect ( firstSixHeaders ) . toEqual ( [ 'ID' , 'ID' , 'ID' , 'ID' , 'CompanyName' , 'ContactName' ] ) ;
161
+
162
+ ( componentInstance as BlueWhaleGridComponent ) . extraMissingColumn = true ;
163
+ fixture . detectChanges ( ) ;
164
+
165
+ firstGroupChildrenCount = 2 ;
166
+ firstGroup = GridFunctions . getColumnGroupHeaders ( fixture ) [ 0 ] ;
167
+ testColumnGroupHeaderRendering ( firstGroup , firstGroupChildrenCount * columnWidthPx ,
168
+ gridHeadersDepth * grid . defaultRowHeight , componentInstance . firstGroupTitle ,
169
+ 'firstGroupColumn' , firstGroupChildrenCount ) ;
170
+
171
+ allHeaders = GridFunctions . getColumnHeaders ( fixture ) . map < IgxGridHeaderComponent > ( x => x . componentInstance ) ;
172
+ firstSixHeaders = allHeaders . slice ( 0 , 6 ) . map ( x => x . column . field ) ;
173
+ expect ( allHeaders . length ) . toEqual ( 15 ) ;
174
+ expect ( firstSixHeaders ) . toEqual ( [ 'ID' , 'Missing' , 'ID' , 'ID' , 'ID' , 'CompanyName' ] ) ;
175
+ } ) ;
176
+
138
177
it ( 'Should not render empty column group.' , ( ) => {
139
178
fixture = TestBed . createComponent ( ColumnGroupTestComponent ) ;
140
179
fixture . detectChanges ( ) ;
0 commit comments