@@ -124,26 +124,36 @@ describe('IgxGrid - Grid Sorting #grid', () => {
124
124
expect ( grid . getCellByColumn ( grid . data . length - 1 , firstColumn ) . value ) . toEqual ( 6 ) ;
125
125
expect ( grid . getCellByColumn ( grid . data . length - 1 , thirdColumn ) . value ) . toEqual ( 'Jones' ) ;
126
126
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
+
127
131
// Clear sorting on a column
128
132
grid . clearSort ( firstColumn ) ;
129
133
fixture . detectChanges ( ) ;
130
134
131
135
expect ( grid . sortingExpressions . length ) . toEqual ( 1 ) ;
132
136
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 ) ;
133
139
134
140
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 }
137
143
] ;
138
144
fixture . detectChanges ( ) ;
139
145
140
146
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 ) ;
141
149
142
150
// Clear sorting on all columns
143
151
grid . clearSort ( ) ;
144
152
fixture . detectChanges ( ) ;
145
153
146
154
expect ( grid . sortingExpressions . length ) . toEqual ( 0 ) ;
155
+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( firstColumn , fixture ) ) ) . toBeNull ( ) ;
156
+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( secondColumn , fixture ) ) ) . toBeNull ( ) ;
147
157
} ) ;
148
158
149
159
it ( 'Should sort grid by multiple expressions through API using ignoreCase for the second expression' , ( ) => {
@@ -202,6 +212,7 @@ describe('IgxGrid - Grid Sorting #grid', () => {
202
212
expect ( grid . getCellByColumn ( grid . data . length - 1 , secondColumn ) . value ) . toEqual ( 'ALex' ) ;
203
213
expect ( grid . getCellByColumn ( grid . data . length - 1 , thirdColumn ) . value ) . toEqual ( 'Smith' ) ;
204
214
expect ( grid . getCellByColumn ( grid . data . length - 1 , firstColumn ) . value ) . toEqual ( 5 ) ;
215
+
205
216
} ) ;
206
217
207
218
it ( `Should allow sorting using a custom Sorting Strategy.` , ( ) => {
@@ -246,6 +257,7 @@ describe('IgxGrid - Grid Sorting #grid', () => {
246
257
const lastRowSecondCell = GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ;
247
258
expect ( GridFunctions . getValueFromCellElement ( lastRowFirstCell ) ) . toEqual ( '7' ) ;
248
259
expect ( GridFunctions . getValueFromCellElement ( lastRowSecondCell ) ) . toEqual ( 'Rick' ) ;
260
+
249
261
} ) ;
250
262
251
263
it ( 'Should sort grid descending by clicking twice on sort icon UI' , ( ) => {
@@ -274,6 +286,7 @@ describe('IgxGrid - Grid Sorting #grid', () => {
274
286
fixture . detectChanges ( ) ;
275
287
GridFunctions . clickHeaderSortIcon ( firstHeaderCell ) ;
276
288
fixture . detectChanges ( ) ;
289
+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( 'ID' , fixture ) ) ) . toEqual ( 1 ) ;
277
290
GridFunctions . clickHeaderSortIcon ( firstHeaderCell ) ;
278
291
fixture . detectChanges ( ) ;
279
292
@@ -283,6 +296,8 @@ describe('IgxGrid - Grid Sorting #grid', () => {
283
296
const lastRowSecondCell = GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ;
284
297
expect ( GridFunctions . getValueFromCellElement ( lastRowSecondCell ) ) . toEqual ( 'Connor' ) ;
285
298
299
+ expect ( GridFunctions . getColumnSortingIndex ( GridFunctions . getColumnHeader ( 'ID' , fixture ) ) ) . toBeNull ( ) ;
300
+
286
301
} ) ;
287
302
288
303
it ( 'Should have a valid sorting icon when sorting using the API.' , ( ) => {
@@ -297,7 +312,6 @@ describe('IgxGrid - Grid Sorting #grid', () => {
297
312
fixture . detectChanges ( ) ;
298
313
299
314
GridFunctions . verifyHeaderSortIndicator ( firstHeaderCell , false , true ) ;
300
-
301
315
grid . clearSort ( ) ;
302
316
fixture . detectChanges ( ) ;
303
317
GridFunctions . verifyHeaderSortIndicator ( firstHeaderCell , false , false ) ;
@@ -345,13 +359,17 @@ describe('IgxGrid - Grid Sorting #grid', () => {
345
359
// tslint:disable-next-line: max-line-length
346
360
expect ( GridFunctions . getValueFromCellElement ( GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ) ) . toEqual ( 'Connor' ) ;
347
361
362
+ expect ( GridFunctions . getColumnSortingIndex ( firstHeaderCell ) ) . toEqual ( 1 ) ;
363
+
348
364
GridFunctions . clickHeaderSortIcon ( firstHeaderCell ) ;
349
365
fixture . detectChanges ( ) ;
350
366
351
367
// Verify that the grid is NOT sorted.
352
368
expect ( GridFunctions . getValueFromCellElement ( GridFunctions . getCurrentCellFromGrid ( grid , 0 , 1 ) ) ) . toEqual ( 'Jane' ) ;
353
369
// tslint:disable-next-line: max-line-length
354
370
expect ( GridFunctions . getValueFromCellElement ( GridFunctions . getCurrentCellFromGrid ( grid , grid . data . length - 1 , 1 ) ) ) . toEqual ( 'Connor' ) ;
371
+
372
+ expect ( GridFunctions . getColumnSortingIndex ( firstHeaderCell ) ) . toEqual ( 1 ) ;
355
373
} ) ;
356
374
} ) ;
357
375
} ) ;
0 commit comments