Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -0,0 +1,57 @@
import { describe, expect, test } from "vitest";
import { formatRelativeTime } from "./date.js";
// Coverage gap: the unit-selection cascade in `formatRelativeTime` was only
// exercised for days/hours. These tests walk the larger units (year/month),
// the sub-minute fallback to "second", the zero-delta case, and the
// `relativeTo` overload variants (Date vs number vs default-now).
describe("formatRelativeTime — unit cascade", () => {
test("selects years for multi-year deltas", () => {
const now = new Date("2026-05-17T12:00:00Z");
const earlier = new Date("2024-05-17T12:00:00Z");
expect(formatRelativeTime(earlier, { locale: "en-US", relativeTo: now, numeric: "always" })).toBe("2 years ago");
expect(formatRelativeTime(earlier, { locale: "de-DE", relativeTo: now, numeric: "always" })).toBe("vor 2 Jahren");
});
test("selects months for deltas under a year but over a month", () => {
const now = new Date("2026-05-17T12:00:00Z");
const earlier = new Date("2026-03-17T12:00:00Z");
expect(formatRelativeTime(earlier, { locale: "en-US", relativeTo: now, numeric: "always" })).toBe("2 months ago");
});
test("falls through to seconds for sub-minute deltas", () => {
const now = new Date("2026-05-17T12:00:30Z");
const earlier = new Date("2026-05-17T12:00:00Z");
expect(formatRelativeTime(earlier, { locale: "en-US", relativeTo: now, numeric: "always" })).toBe("30 seconds ago");
});
test("renders a zero delta as the seconds floor", () => {
const now = new Date("2026-05-17T12:00:00Z");
// Identical instants → delta 0 → no unit threshold met until the trailing
// `unit === "second"` short-circuit fires with a rounded value of 0.
expect(formatRelativeTime(now, { locale: "en-US", relativeTo: now, numeric: "always" })).toBe("in 0 seconds");
});
});
describe("formatRelativeTime — relativeTo overloads", () => {
test("accepts a numeric (epoch ms) anchor", () => {
const now = new Date("2026-05-17T12:00:00Z");
const earlier = new Date("2026-05-14T12:00:00Z");
expect(formatRelativeTime(earlier, { locale: "en-US", relativeTo: now.getTime(), numeric: "always" })).toBe("3 days ago");
});
test("accepts a numeric (epoch ms) target value", () => {
const now = new Date("2026-05-17T12:00:00Z");
const earlier = new Date("2026-05-14T12:00:00Z");
expect(formatRelativeTime(earlier.getTime(), { locale: "en-US", relativeTo: now, numeric: "always" })).toBe("3 days ago");
});
test("anchors to the current time when relativeTo is omitted", () => {
// No `relativeTo` → anchor falls back to `Date.now()`. A target three hours
// in the future stays well clear of the rounding boundary, so the assertion
// is stable despite the few-ms gap between target build and now().
const future = new Date(Date.now() + 3 * 60 * 60 * 1000);
expect(formatRelativeTime(future, { locale: "en-US", numeric: "always" })).toBe("in 3 hours");
});
});