tobogganSe connecter

starfleet-ui

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

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