import { describe, it, expect } from 'vitest'; import { DateFormatter } from './DateFormatter'; describe('DateFormatter', () => { describe('formatShort', () => { it('should format date as "Jan 18, 2026"', () => { const date = new Date('2026-01-18T12:00:00Z'); expect(DateFormatter.formatShort(date)).toBe('Jan 18, 2026'); }); it('should handle string input', () => { expect(DateFormatter.formatShort('2026-01-18T12:00:00Z')).toBe('Jan 18, 2026'); }); it('should format different months correctly', () => { expect(DateFormatter.formatShort(new Date('2026-02-15T12:00:00Z'))).toBe('Feb 15, 2026'); expect(DateFormatter.formatShort(new Date('2026-12-25T12:00:00Z'))).toBe('Dec 25, 2026'); }); it('should handle single digit days', () => { expect(DateFormatter.formatShort(new Date('2026-01-05T12:00:00Z'))).toBe('Jan 5, 2026'); }); }); describe('formatMonthYear', () => { it('should format date as "Jan 2026"', () => { const date = new Date('2026-01-18T12:00:00Z'); expect(DateFormatter.formatMonthYear(date)).toBe('Jan 2026'); }); it('should handle string input', () => { expect(DateFormatter.formatMonthYear('2026-01-18T12:00:00Z')).toBe('Jan 2026'); }); it('should format different months correctly', () => { expect(DateFormatter.formatMonthYear(new Date('2026-02-15T12:00:00Z'))).toBe('Feb 2026'); expect(DateFormatter.formatMonthYear(new Date('2026-12-25T12:00:00Z'))).toBe('Dec 2026'); }); }); describe('formatTime', () => { it('should format time as "15:00"', () => { const date = new Date('2026-01-18T15:00:00Z'); expect(DateFormatter.formatTime(date)).toBe('15:00'); }); it('should handle string input', () => { expect(DateFormatter.formatTime('2026-01-18T15:00:00Z')).toBe('15:00'); }); it('should pad single digit hours and minutes', () => { expect(DateFormatter.formatTime(new Date('2026-01-18T05:09:00Z'))).toBe('05:09'); }); it('should handle midnight', () => { expect(DateFormatter.formatTime(new Date('2026-01-18T00:00:00Z'))).toBe('00:00'); }); }); describe('formatMonthDay', () => { it('should format date as "Jan 18"', () => { const date = new Date('2026-01-18T12:00:00Z'); expect(DateFormatter.formatMonthDay(date)).toBe('Jan 18'); }); it('should handle string input', () => { expect(DateFormatter.formatMonthDay('2026-01-18T12:00:00Z')).toBe('Jan 18'); }); it('should format different months correctly', () => { expect(DateFormatter.formatMonthDay(new Date('2026-02-15T12:00:00Z'))).toBe('Feb 15'); expect(DateFormatter.formatMonthDay(new Date('2026-12-25T12:00:00Z'))).toBe('Dec 25'); }); it('should handle single digit days', () => { expect(DateFormatter.formatMonthDay(new Date('2026-01-05T12:00:00Z'))).toBe('Jan 5'); }); }); describe('formatDateTime', () => { it('should format date and time as "Jan 18, 15:00"', () => { const date = new Date('2026-01-18T15:00:00Z'); expect(DateFormatter.formatDateTime(date)).toBe('Jan 18, 15:00'); }); it('should handle string input', () => { expect(DateFormatter.formatDateTime('2026-01-18T15:00:00Z')).toBe('Jan 18, 15:00'); }); it('should pad single digit hours and minutes', () => { expect(DateFormatter.formatDateTime(new Date('2026-01-18T05:09:00Z'))).toBe('Jan 18, 05:09'); }); it('should handle midnight', () => { expect(DateFormatter.formatDateTime(new Date('2026-01-18T00:00:00Z'))).toBe('Jan 18, 00:00'); }); }); });