File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,4 +129,15 @@ describe('applyDeterministicVariation', () => {
129129 // Empty seed should return original value without variation
130130 expect ( result ) . toBe ( baseValue ) ;
131131 } ) ;
132+
133+ it ( 'should handle falsy value' , ( ) => {
134+ const result = applyDeterministicVariation ( {
135+ value : null as unknown as number ,
136+ seed : '' ,
137+ maxVariationPercent : 7.6 ,
138+ } ) ;
139+
140+ // Empty seed should return original value without variation
141+ expect ( result ) . toBe ( 0 ) ;
142+ } ) ;
132143} ) ;
Original file line number Diff line number Diff line change 1+ import { isNullOrUndefined } from './object' ;
2+
13export function largeNumberFormat ( value : number ) : string | null {
24 if ( typeof value !== 'number' ) {
35 return null ;
@@ -81,6 +83,10 @@ export const applyDeterministicVariation = ({
8183 seed : string ;
8284 maxVariationPercent : number ;
8385} ) : number => {
86+ if ( isNullOrUndefined ( value ) ) {
87+ return 0 ;
88+ }
89+
8490 if ( ! seed ) {
8591 return value ;
8692 }
You can’t perform that action at this time.
0 commit comments