Files
nanobot/webui/src/tests/context-graph-canvas.test.ts
T

11 lines
519 B
TypeScript
Raw Normal View History

import { expect, it, vi } from "vitest";
import { fitGraphLabel } from "@/components/thread/graph-canvas";
it("fits long Unicode labels with bounded measurements and complete code points", () => {
const name = "😀".repeat(255);
const measure = vi.fn((text: string) => Array.from(text).length);
const fitted = fitGraphLabel(name, measure);
expect(fitted).toBe(`${"😀".repeat(127)}…`);
expect(measure.mock.calls.length).toBeLessThanOrEqual(10);
expect(fitGraphLabel("a.md", measure)).toBe("a.md");
});