import { describe, expect, it } from 'vitest'; import { formatDateValue, parseDateValue } from './date-value'; describe('parseDateValue', () => { it('returns null for empty values', () => { expect(parseDateValue(null)).toBeNull(); expect(parseDateValue(undefined)).toBeNull(); expect(parseDateValue('')).toBeNull(); }); it('parses YYYY-MM-DD strings', () => { const date = parseDateValue('2026-01-12'); expect(date).toBeInstanceOf(Date); expect(formatDateValue(date)).toBe('2026-01-12'); }); it('parses unix milliseconds', () => { const date = parseDateValue(new Date(2026, 0, 12).getTime()); expect(formatDateValue(date)).toBe('2026-01-12'); }); }); describe('formatDateValue', () => { it('formats a Date as YYYY-MM-DD', () => { expect(formatDateValue(new Date(2026, 0, 12))).toBe('2026-01-12'); }); it('returns an empty string for empty values', () => { expect(formatDateValue(null)).toBe(''); expect(formatDateValue(undefined)).toBe(''); }); });