Skip to content

Commit 26c980f

Browse files
committed
✅ (dev): Add numberWithCommas fallback tests
1 parent e2f058e commit 26c980f

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

test/spec/lib/helper.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,33 @@ describe('Helper', function () {
396396
expect(numberWithCommas('0')).to.eql('0');
397397
expect(numberWithCommas('-1234')).to.eql('-1,234');
398398
});
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+
});
425+
});
399426
});
400427

401428
describe('prettyPrintArray()', function () {

0 commit comments

Comments
 (0)