File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
core/src/utils/floating-point Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,24 @@ describe('floating point utils', () => {
1111 const n = getDecimalPlaces ( 5 ) ;
1212 expect ( n ) . toBe ( 0 ) ;
1313 } ) ;
14+
15+ it ( 'should handle nullish values' , ( ) => {
16+ expect ( getDecimalPlaces ( undefined as any ) ) . toBe ( 0 ) ;
17+ expect ( getDecimalPlaces ( null as any ) ) . toBe ( 0 ) ;
18+ expect ( getDecimalPlaces ( NaN as any ) ) . toBe ( 0 ) ;
19+ } ) ;
1420 } ) ;
1521
1622 describe ( 'roundToMaxDecimalPlaces' , ( ) => {
1723 it ( 'should round to the highest number of places as references' , async ( ) => {
1824 const n = roundToMaxDecimalPlaces ( 5.12345 , 1.12 , 2.123 ) ;
1925 expect ( n ) . toBe ( 5.123 ) ;
2026 } ) ;
27+
28+ it ( 'should handle nullish values' , ( ) => {
29+ expect ( roundToMaxDecimalPlaces ( undefined as any ) ) . toBe ( 0 ) ;
30+ expect ( roundToMaxDecimalPlaces ( null as any ) ) . toBe ( 0 ) ;
31+ expect ( roundToMaxDecimalPlaces ( NaN as any ) ) . toBe ( 0 ) ;
32+ } )
2133 } ) ;
2234} ) ;
You can’t perform that action at this time.
0 commit comments