@@ -124,26 +124,36 @@ describe('IgxGrid - Grid Sorting #grid', () => {
124124 expect ( grid . getCellByColumn ( grid . data . length - 1 , firstColumn ) . value ) . toEqual ( 6 ) ;
125125 expect ( grid . getCellByColumn ( grid . data . length - 1 , thirdColumn ) . value ) . toEqual ( 'Jones' ) ;
126126
127+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( secondColumn , fixture ) ) ) . toEqual ( 1 ) ;
128+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( firstColumn , fixture ) ) ) . toEqual ( 2 ) ;
129+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( thirdColumn , fixture ) ) ) . toBeNull ( ) ;
130+
127131 // Clear sorting on a column
128132 grid . clearSort ( firstColumn ) ;
129133 fixture . detectChanges ( ) ;
130134
131135 expect ( grid . sortingExpressions . length ) . toEqual ( 1 ) ;
132136 expect ( grid . sortingExpressions [ 0 ] . fieldName ) . toEqual ( secondColumn ) ;
137+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( firstColumn , fixture ) ) ) . toBeNull ( ) ;
138+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( secondColumn , fixture ) ) ) . toEqual ( 1 ) ;
133139
134140 grid . sortingExpressions = [
135- { fieldName : secondColumn , dir : SortingDirection . Asc , ignoreCase : true } ,
136- { fieldName : firstColumn , dir : SortingDirection . Desc , ignoreCase : true }
141+ { fieldName : firstColumn , dir : SortingDirection . Desc , ignoreCase : true } ,
142+ { fieldName : secondColumn , dir : SortingDirection . Asc , ignoreCase : true }
137143 ] ;
138144 fixture . detectChanges ( ) ;
139145
140146 expect ( grid . sortingExpressions . length ) . toEqual ( 2 ) ;
147+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( firstColumn , fixture ) ) ) . toEqual ( 1 ) ;
148+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( secondColumn , fixture ) ) ) . toEqual ( 2 ) ;
141149
142150 // Clear sorting on all columns
143151 grid . clearSort ( ) ;
144152 fixture . detectChanges ( ) ;
145153
146154 expect ( grid . sortingExpressions . length ) . toEqual ( 0 ) ;
155+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( firstColumn , fixture ) ) ) . toBeNull ( ) ;
156+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( secondColumn , fixture ) ) ) . toBeNull ( ) ;
147157 } ) ;
148158
149159 it ( 'Should sort grid by multiple expressions through API using ignoreCase for the second expression' , ( ) => {
@@ -202,6 +212,7 @@ describe('IgxGrid - Grid Sorting #grid', () => {
202212 expect ( grid . getCellByColumn ( grid . data . length - 1 , secondColumn ) . value ) . toEqual ( 'ALex' ) ;
203213 expect ( grid . getCellByColumn ( grid . data . length - 1 , thirdColumn ) . value ) . toEqual ( 'Smith' ) ;
204214 expect ( grid . getCellByColumn ( grid . data . length - 1 , firstColumn ) . value ) . toEqual ( 5 ) ;
215+
205216 } ) ;
206217
207218 it ( `Should allow sorting using a custom Sorting Strategy.` , ( ) => {
@@ -246,6 +257,7 @@ describe('IgxGrid - Grid Sorting #grid', () => {
246257 const lastRowSecondCell = GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ;
247258 expect ( GridFunctions . getValueFromCellElement ( lastRowFirstCell ) ) . toEqual ( '7' ) ;
248259 expect ( GridFunctions . getValueFromCellElement ( lastRowSecondCell ) ) . toEqual ( 'Rick' ) ;
260+
249261 } ) ;
250262
251263 it ( 'Should sort grid descending by clicking twice on sort icon UI' , ( ) => {
@@ -274,6 +286,7 @@ describe('IgxGrid - Grid Sorting #grid', () => {
274286 fixture . detectChanges ( ) ;
275287 GridFunctions . clickHeaderSortIcon ( firstHeaderCell ) ;
276288 fixture . detectChanges ( ) ;
289+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( 'ID' , fixture ) ) ) . toEqual ( 1 ) ;
277290 GridFunctions . clickHeaderSortIcon ( firstHeaderCell ) ;
278291 fixture . detectChanges ( ) ;
279292
@@ -283,6 +296,8 @@ describe('IgxGrid - Grid Sorting #grid', () => {
283296 const lastRowSecondCell = GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ;
284297 expect ( GridFunctions . getValueFromCellElement ( lastRowSecondCell ) ) . toEqual ( 'Connor' ) ;
285298
299+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( 'ID' , fixture ) ) ) . toBeNull ( ) ;
300+
286301 } ) ;
287302
288303 it ( 'Should have a valid sorting icon when sorting using the API.' , ( ) => {
@@ -297,7 +312,6 @@ describe('IgxGrid - Grid Sorting #grid', () => {
297312 fixture . detectChanges ( ) ;
298313
299314 GridFunctions . verifyHeaderSortIndicator ( firstHeaderCell , false , true ) ;
300-
301315 grid . clearSort ( ) ;
302316 fixture . detectChanges ( ) ;
303317 GridFunctions . verifyHeaderSortIndicator ( firstHeaderCell , false , false ) ;
@@ -345,13 +359,17 @@ describe('IgxGrid - Grid Sorting #grid', () => {
345359 // tslint:disable-next-line: max-line-length
346360 expect ( GridFunctions . getValueFromCellElement ( GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ) ) . toEqual ( 'Connor' ) ;
347361
362+ expect ( GridFunctions . getColumnSortingIndex ( firstHeaderCell ) ) . toEqual ( 1 ) ;
363+
348364 GridFunctions . clickHeaderSortIcon ( firstHeaderCell ) ;
349365 fixture . detectChanges ( ) ;
350366
351367 // Verify that the grid is NOT sorted.
352368 expect ( GridFunctions . getValueFromCellElement ( GridFunctions . getCurrentCellFromGrid ( grid , 0 , 1 ) ) ) . toEqual ( 'Jane' ) ;
353369 // tslint:disable-next-line: max-line-length
354370 expect ( GridFunctions . getValueFromCellElement ( GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ) ) . toEqual ( 'Connor' ) ;
371+
372+ expect ( GridFunctions . getColumnSortingIndex ( firstHeaderCell ) ) . toEqual ( 1 ) ;
355373 } ) ;
356374 } ) ;
357375} ) ;
0 commit comments