import { describe, expect, it } from 'vitest' import { formatRelativeDate } from '../relativeDate' const now = new Date('2026-08-25T12:00:00Z') describe('formatRelativeDate', () => { it('formats under an hour in minutes', () => { expect(formatRelativeDate('2026-08-25T11:45:00Z', now)).toBe('15 minutes ago') }) it('clamps a sub-minute difference to "1 minute ago"', () => { expect(formatRelativeDate('2026-08-25T11:59:45Z', now)).toBe('1 minute ago') }) it('uses the singular for exactly one minute ago', () => { expect(formatRelativeDate('2026-08-25T11:59:00Z', now)).toBe('1 minute ago') }) it('formats under a day in hours', () => { expect(formatRelativeDate('2026-08-25T10:00:00Z', now)).toBe('2 hours ago') }) it('uses the singular for exactly one hour ago', () => { expect(formatRelativeDate('2026-08-25T11:00:00Z', now)).toBe('1 hour ago') }) it('formats exactly one day back as Yesterday', () => { expect(formatRelativeDate('2026-08-24T11:00:00Z', now)).toBe('Yesterday') }) it('formats within the week in days', () => { expect(formatRelativeDate('2026-08-22T12:00:00Z', now)).toBe('3 days ago') }) it('formats exactly 7 days ago as an absolute date, not "7 days ago"', () => { expect(formatRelativeDate('2026-08-18T12:00:00Z', now)).toBe('18 Aug 2026') }) it('formats a week or more ago as an absolute date', () => { expect(formatRelativeDate('2026-08-10T12:00:00Z', now)).toBe('10 Aug 2026') }) })