Files
coder/site/src/utils/analytics.test.ts
T
Michael Suchacz 7cca2b6176 feat(site): add chat spend limit UI (#23072)
Frontend for agent chat spend limiting on `/agents`.

## Changes
- add the limits management UI, API hooks, and validation for
deployment, group, and user overrides
- show spend limit status in Agents analytics and usage summaries
- surface limit-related chat errors consistently in the agent detail
experience
- add shared currency and usage-limit messaging helpers plus related
stories/tests
2026-03-17 02:01:51 +01:00

25 lines
765 B
TypeScript

import { describe, expect, it } from "vitest";
import { formatTokenCount } from "./analytics";
describe("formatTokenCount", () => {
it("formats zero values", () => {
expect(formatTokenCount(0)).toBe("0");
});
it("formats normal values with locale separators", () => {
expect(formatTokenCount(999)).toBe("999");
expect(formatTokenCount(1_234)).toBe("1,234");
expect(formatTokenCount(999_999)).toBe("999,999");
});
it("formats large values in millions", () => {
expect(formatTokenCount(1_000_000)).toBe("1M");
expect(formatTokenCount(1_500_000)).toBe("1.5M");
expect(formatTokenCount(2_000_000)).toBe("2M");
});
it("rounds million values to one decimal place when needed", () => {
expect(formatTokenCount(1_250_000)).toBe("1.3M");
});
});