Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 54s
33 lines
959 B
TypeScript
33 lines
959 B
TypeScript
// src/utils/formatUtils.test.ts
|
|
import { describe, it, expect } from 'vitest';
|
|
import { formatCurrency } from './formatUtils';
|
|
|
|
describe('formatCurrency', () => {
|
|
it('should format a positive integer of cents correctly', () => {
|
|
expect(formatCurrency(199)).toBe('$1.99');
|
|
});
|
|
|
|
it('should format a larger number of cents correctly', () => {
|
|
expect(formatCurrency(12345)).toBe('$123.45');
|
|
});
|
|
|
|
it('should handle single-digit cents correctly', () => {
|
|
expect(formatCurrency(5)).toBe('$0.05');
|
|
});
|
|
|
|
it('should handle zero cents correctly', () => {
|
|
expect(formatCurrency(0)).toBe('$0.00');
|
|
});
|
|
|
|
it('should return "N/A" for a null input', () => {
|
|
expect(formatCurrency(null)).toBe('N/A');
|
|
});
|
|
|
|
it('should return "N/A" for an undefined input', () => {
|
|
expect(formatCurrency(undefined)).toBe('N/A');
|
|
});
|
|
|
|
it('should handle negative cents correctly', () => {
|
|
expect(formatCurrency(-500)).toBe('-$5.00');
|
|
});
|
|
}); |