Files
classroomio/apps/dashboard/src/lib/utils/functions/getCurrencyFormatter.spec.ts
T

28 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-12-20 11:28:40 +00:00
import getCurrencyFormatter from './getCurrencyFormatter';
describe('GetCurrencyFormatter', () => {
test('should return a new instance of Intl.NumberFormat with the correct locale and currency options when currency is "NGN"', () => {
const result = getCurrencyFormatter('NGN');
expect(result).toBeInstanceOf(Intl.NumberFormat);
expect(result.resolvedOptions().locale).toBe('en-NG');
expect(result.resolvedOptions().currency).toBe('NGN');
expect(result.resolvedOptions().minimumFractionDigits).toBe(2);
});
test('should return a new instance of Intl.NumberFormat with the correct locale and currency options when currency is "USD"', () => {
const result = getCurrencyFormatter('USD');
expect(result).toBeInstanceOf(Intl.NumberFormat);
expect(result.resolvedOptions().locale).toBe('en-US');
expect(result.resolvedOptions().currency).toBe('USD');
expect(result.resolvedOptions().minimumFractionDigits).toBe(2);
});
test('should return a new instance of Intl.NumberFormat with the correct locale and currency options when currency is "EUR"', () => {
const result = getCurrencyFormatter('EUR');
expect(result).toBeInstanceOf(Intl.NumberFormat);
expect(result.resolvedOptions().locale).toBe('en-US');
expect(result.resolvedOptions().currency).toBe('EUR');
expect(result.resolvedOptions().minimumFractionDigits).toBe(2);
});
});