@@ -385,12 +385,43 @@ describe('Helper', function () {
385385 expect ( numberWithCommas ( 123 ) ) . to . eql ( '123' ) ;
386386 expect ( numberWithCommas ( 1234 ) ) . to . eql ( '1,234' ) ;
387387 expect ( numberWithCommas ( 1234567890 ) ) . to . eql ( '1,234,567,890' ) ;
388+ expect ( numberWithCommas ( 0 ) ) . to . eql ( '0' ) ;
389+ expect ( numberWithCommas ( - 1234 ) ) . to . eql ( '-1,234' ) ;
388390 } ) ;
389391
390392 it ( 'Works with number string' , function ( ) {
391393 expect ( numberWithCommas ( '123' ) ) . to . eql ( '123' ) ;
392394 expect ( numberWithCommas ( '1234' ) ) . to . eql ( '1,234' ) ;
393395 expect ( numberWithCommas ( '1234567890' ) ) . to . eql ( '1,234,567,890' ) ;
396+ expect ( numberWithCommas ( '0' ) ) . to . eql ( '0' ) ;
397+ expect ( numberWithCommas ( '-1234' ) ) . to . eql ( '-1,234' ) ;
398+ } ) ;
399+
400+ describe ( 'Fallback logic when Intl is not available' , function ( ) {
401+ let originalIntl : any ;
402+
403+ beforeEach ( function ( ) {
404+ // Save original Intl
405+ originalIntl = ( global as any ) . Intl ;
406+ } ) ;
407+
408+ afterEach ( function ( ) {
409+ // Restore original Intl
410+ ( global as any ) . Intl = originalIntl ;
411+ } ) ;
412+
413+ it ( 'should use fallback logic when Intl is not available' , function ( ) {
414+ // Remove Intl
415+ delete ( global as any ) . Intl ;
416+
417+ expect ( numberWithCommas ( 123 ) ) . to . eql ( '123' ) ;
418+ expect ( numberWithCommas ( 1234 ) ) . to . eql ( '1,234' ) ;
419+ expect ( numberWithCommas ( 1234567890 ) ) . to . eql ( '1,234,567,890' ) ;
420+ expect ( numberWithCommas ( 0 ) ) . to . eql ( '0' ) ;
421+ expect ( numberWithCommas ( - 1234 ) ) . to . eql ( '-1,234' ) ;
422+ expect ( numberWithCommas ( 1234.56 ) ) . to . eql ( '1,234.56' ) ;
423+ expect ( numberWithCommas ( - 1234.56 ) ) . to . eql ( '-1,234.56' ) ;
424+ } ) ;
394425 } ) ;
395426 } ) ;
396427
0 commit comments