Files
flyer-crawler.projectium.com/src/utils/formatUtils.test.ts
Torben Sorensen 4e20b1b430
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 54s
even more and more test fixes
2026-01-05 01:26:12 -08:00

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');
});
});