@@ -109,4 +109,18 @@ describe('table/helpers/default-sort-compare', () => {
109
109
expect ( defaultSortCompare ( x , w , optionsNullLast ) ) . toBe ( - 1 )
110
110
expect ( defaultSortCompare ( w , x , optionsNullLast ) ) . toBe ( 1 )
111
111
} )
112
+
113
+ it ( 'sorts numeric string correctly' , async ( ) => {
114
+ const options = { sortBy : 'a' , numeric : true }
115
+ expect ( defaultSortCompare ( { a : '1' } , { a : '2' } , options ) ) . toBe ( - 1 )
116
+ expect ( defaultSortCompare ( { a : '2' } , { a : '1' } , options ) ) . toBe ( 1 )
117
+ expect ( defaultSortCompare ( { a : '1' } , { a : '1' } , options ) ) . toBe ( 0 )
118
+ expect ( defaultSortCompare ( { a : '-1' } , { a : '1' } , options ) ) . toBe ( - 1 )
119
+ expect ( defaultSortCompare ( { a : '1' } , { a : '-1' } , options ) ) . toBe ( 1 )
120
+ expect ( defaultSortCompare ( { a : '0' } , { a : '0' } , options ) ) . toBe ( 0 )
121
+ expect ( defaultSortCompare ( { a : '1.234' } , { a : '1.567' } , options ) ) . toBe ( - 1 )
122
+ expect ( defaultSortCompare ( { a : '1.561' } , { a : '1.234' } , options ) ) . toBe ( 1 )
123
+ expect ( defaultSortCompare ( { a : '-10' } , { a : '-100' } , options ) ) . toBe ( 1 )
124
+ expect ( defaultSortCompare ( { a : '-20' } , { a : '-30' } , options ) ) . toBe ( 1 )
125
+ } )
112
126
} )
0 commit comments