import { describe, expect, it } from "vitest"; import {
formatUsageReportLines,
formatUsageSummaryLine,
formatUsageWindowSummary,
} from "./provider-usage.format.js"; import type { ProviderUsageSnapshot, UsageSummary } from "./provider-usage.types.js";
expect(summary).toContain("Now 90% left ⏱now");
expect(summary).toContain("Minute 80% left ⏱30m");
expect(summary).toContain("Hour 70% left ⏱2h 15m");
expect(summary).toContain("Day 60% left ⏱2d 3h");
expect(summary).toMatch(/Date 50% left ⏱[A-Z][a-z]{2} \d{1,2}/);
});
it("honors max windows and reset toggle", () => { const summary = formatUsageWindowSummary(
makeSnapshot([
{ label: "A", usedPercent: 10, resetAt: now + 60_000 },
{ label: "B", usedPercent: 20, resetAt: now + 120_000 },
{ label: "C", usedPercent: 30, resetAt: now + 180_000 },
]),
{ now, maxWindows: 2, includeResets: false },
);
expect(summary).toBe("A 90% left · B 80% left");
});
it("treats non-positive max windows as all windows and clamps overused percentages", () => { const summary = formatUsageWindowSummary(
makeSnapshot([
{ label: "Over", usedPercent: 120, resetAt: now + 60_000 },
{ label: "Under", usedPercent: -10 },
]),
{ now, maxWindows: 0, includeResets: true },
);
expect(summary).toBe("Over 0% left ⏱1m · Under 100% left");
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.