frequi_origin/tests/unit/formatters.spec.ts

14 lines
513 B
TypeScript
Raw Normal View History

2021-12-30 08:38:43 +00:00
import { formatPercent, formatPriceCurrency } from '@/shared/formatters';
2021-12-18 10:16:15 +00:00
describe('formatters.ts', () => {
it('Format percent correctly', () => {
expect(formatPercent(0.5)).toEqual('50.000%');
});
2021-12-30 08:38:43 +00:00
it('format price currency as expected', () => {
expect(formatPriceCurrency(5123.551123, 'USDT', 3)).toEqual('5123.551 USDT');
expect(formatPriceCurrency(5123.551123, 'USDT')).toEqual('5123.551 USDT');
expect(formatPriceCurrency(5123.551123, 'USDT', 5)).toEqual('5123.55112 USDT');
});
2021-12-18 10:16:15 +00:00
});