@@ -24,34 +24,46 @@ describe('Unit testing SortingStrategy', () => {
2424 strategy : DefaultSortingStrategy . instance ( )
2525 } ] ) ;
2626 expect ( dataGenerator . getValuesForColumn ( res , 'number' ) )
27- . toEqual ( [ 4 , 2 , 0 , 3 , 1 ] ) ;
27+ . toEqual ( [ 4 , 2 , 0 , 3 , 1 ] ) ;
2828 } ) ;
2929 it ( 'tests `compareObjects`' , ( ) => {
3030 const strategy = DefaultSortingStrategy . instance ( ) ;
3131 expect ( strategy . compareValues ( 1 , 0 ) === 1 &&
32- strategy . compareValues ( true , false ) === 1 &&
33- strategy . compareValues ( 'bc' , 'adfc' ) === 1 )
32+ strategy . compareValues ( true , false ) === 1 &&
33+ strategy . compareValues ( 'bc' , 'adfc' ) === 1 )
3434 . toBeTruthy ( 'compare first argument greater than second' ) ;
3535 expect ( strategy . compareValues ( 1 , 2 ) === - 1 &&
36- strategy . compareValues ( 'a' , 'b' ) === - 1 &&
37- strategy . compareValues ( false , true ) === - 1 )
36+ strategy . compareValues ( 'a' , 'b' ) === - 1 &&
37+ strategy . compareValues ( false , true ) === - 1 )
3838 . toBeTruthy ( 'compare 0, 1' ) ;
3939 expect ( strategy . compareValues ( 0 , 0 ) === 0 &&
40- strategy . compareValues ( true , true ) === 0 &&
41- strategy . compareValues ( 'test' , 'test' ) === 0
42- )
40+ strategy . compareValues ( true , true ) === 0 &&
41+ strategy . compareValues ( 'test' , 'test' ) === 0
42+ )
4343 . toBeTruthy ( 'Comare equal variables' ) ;
4444 } ) ;
4545 it ( 'tests default settings' , ( ) => {
4646 ( data [ 4 ] as { string : string } ) . string = 'ROW' ;
4747 const res = sorting . sort ( data , [ {
48- dir : SortingDirection . Asc ,
49- fieldName : 'string' ,
50- ignoreCase : true ,
51- strategy : DefaultSortingStrategy . instance ( )
52- } ] ) ;
48+ dir : SortingDirection . Asc ,
49+ fieldName : 'string' ,
50+ ignoreCase : true ,
51+ strategy : DefaultSortingStrategy . instance ( )
52+ } ] ) ;
5353 expect ( dataGenerator . getValuesForColumn ( res , 'number' ) )
54- . toEqual ( [ 4 , 0 , 1 , 2 , 3 ] ) ;
54+ . toEqual ( [ 4 , 0 , 1 , 2 , 3 ] ) ;
55+ } ) ;
56+
57+ it ( 'should not sort when sorting direction is None' , ( ) => {
58+ const unsortedData = [ { number : 3 } , { number : 1 } , { number : 4 } , { number : 0 } , { number : 2 } ] ;
59+ const res = sorting . sort ( unsortedData , [ {
60+ dir : SortingDirection . None ,
61+ fieldName : 'number' ,
62+ ignoreCase : false ,
63+ strategy : DefaultSortingStrategy . instance ( )
64+ } ] ) ;
65+ expect ( res . map ( d => d . number ) )
66+ . toEqual ( [ 3 , 1 , 4 , 0 , 2 ] ) ;
5567 } ) ;
5668
5769} ) ;
0 commit comments