Tracer bullet for gitea-axi: runnable npm package on axi-sdk-js with gitea-js as the sole HTTP layer, ESM on Node 20+. - issue list with --state/--limit, default fields, count line from X-Total-Count, type=issues guard, explicit empty state, and next-step suggestions - repo context detection from the git origin remote (SSH/scp/HTTPS), tea credential discovery with the three-way login-matching split, and -R/--repo and --login overrides (flag > env > auto) - token retrieval via tea login helper get: tea's login list JSON carries no token (ADR 0001 amended) - full AxiError classification table with path-based 404 split, TOON errors on stdout, exit codes 0/1/2 - test mode (GITEA_AXI_API_URL/TOKEN/REPO) suppressing subprocesses, fixture server, and vitest suites driving the CLI seam (50 tests)
25 lines
988 B
TypeScript
25 lines
988 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { relativeTime } from "../src/time.js";
|
|
|
|
const now = new Date("2026-07-10T12:00:00Z");
|
|
|
|
describe("relativeTime", () => {
|
|
it("formats each magnitude bucket", () => {
|
|
expect(relativeTime("2026-07-10T11:59:30Z", now)).toBe("just now");
|
|
expect(relativeTime("2026-07-10T11:45:00Z", now)).toBe("15m ago");
|
|
expect(relativeTime("2026-07-10T07:00:00Z", now)).toBe("5h ago");
|
|
expect(relativeTime("2026-07-03T12:00:00Z", now)).toBe("7d ago");
|
|
expect(relativeTime("2026-05-10T12:00:00Z", now)).toBe("2mo ago");
|
|
expect(relativeTime("2024-07-10T12:00:00Z", now)).toBe("2y ago");
|
|
});
|
|
|
|
it("clamps future timestamps to just now", () => {
|
|
expect(relativeTime("2026-07-10T13:00:00Z", now)).toBe("just now");
|
|
});
|
|
|
|
it("returns unknown for missing or invalid input, matching gh-axi", () => {
|
|
expect(relativeTime(undefined, now)).toBe("unknown");
|
|
expect(relativeTime("garbage", now)).toBe("unknown");
|
|
});
|
|
});
|