Skip to content

Commit 71860a7

Browse files
test(formNumber): percent and currency custom format tests
1 parent cea2ac7 commit 71860a7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/numbers.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,22 @@ describe('custom formatting', () => {
351351
expect(formatNumber(-18000, '#,##0')).toEqual("-18,000");
352352
});
353353

354+
it('formats currency', () => {
355+
expect(formatNumber(10, '$#.#')).toEqual("$10");
356+
});
357+
358+
it('formats currency with locale symbol', () => {
359+
expect(formatNumber(10, '#.#$', 'bg')).toEqual("10лв.");
360+
});
361+
362+
it('formats percentage', () => {
363+
expect(formatNumber(0.5, '#.#%')).toEqual("50%");
364+
});
365+
366+
it('percentage does not leave trailing zeros if multiplication by 100 causes rounding error', () => {
367+
expect(formatNumber(0.035, '#.##%')).toEqual("3.5%");
368+
});
369+
354370
it('applies thousand separator to a longer than the pattern number', () => {
355371
expect(formatNumber(1000000.1, '#,###')).toEqual("1,000,000");
356372
});

0 commit comments

Comments
 (0)