import { describe, it, expect } from 'vitest'; import { formatDateTime } from '@/lib/format'; describe('formatDateTime', () => { it('formats a valid ISO string', () => { const result = formatDateTime('2024-01-15T10:30:00Z'); expect(typeof result).toBe('string'); expect(result.length).toBeGreaterThan(0); expect(result).not.toBe('2024-01-15T10:30:00Z'); }); it('returns the raw string for an invalid date', () => { expect(formatDateTime('not-a-date')).toBe('not-a-date'); }); it('returns the raw string for an empty string', () => { expect(formatDateTime('')).toBe(''); }); it('handles date-only ISO strings', () => { const result = formatDateTime('2024-06-01'); expect(typeof result).toBe('string'); expect(result.length).toBeGreaterThan(0); }); it('handles ISO strings with milliseconds', () => { const result = formatDateTime('2024-03-20T14:22:33.456Z'); expect(typeof result).toBe('string'); expect(result).not.toBe('2024-03-20T14:22:33.456Z'); }); it('returns consistent output for the same input', () => { const iso = '2024-07-04T12:00:00Z'; expect(formatDateTime(iso)).toBe(formatDateTime(iso)); }); });