import { expect, test } from 'bun:test'; import { untilLabel } from './time'; const now = Date.parse('2026-11-06T12:00:00Z'); const at = (sec: number) => new Date(now + sec * 1000).toISOString(); test('untilLabel picks the two most significant units', () => { expect(untilLabel(at(38), now)).toBe('38s'); expect(untilLabel(at(4 * 60 + 12), now)).toBe('4m 12s'); expect(untilLabel(at(2 * 3600 + 5 * 60), now)).toBe('2h 05m'); expect(untilLabel(at(3 * 86_400 + 7200), now)).toBe('3d 2h'); }); test('untilLabel clamps the past to zero', () => { expect(untilLabel(at(-60), now)).toBe('0s'); });