readToolCallBlock.test.ts 863 B

123456789101112131415161718192021222324252627
  1. import { createElement } from "react";
  2. import { renderToStaticMarkup } from "react-dom/server";
  3. import { describe, expect, it } from "vitest";
  4. import { ReadFileChip, type ReadSummary } from "@/ToolCallBlocks/renderers/read.js";
  5. const summary: ReadSummary = {
  6. path: "/workspace/src/App.tsx",
  7. fileName: "App.tsx",
  8. filePath: "/workspace/src/",
  9. fileIconSrc: "/material-icons/typescript.svg",
  10. entryType: "file",
  11. };
  12. describe("ReadFileChip", () => {
  13. it.each([false, true])("uses the subtle filename color (clickable=%s)", (clickable) => {
  14. const html = renderToStaticMarkup(
  15. createElement(ReadFileChip, {
  16. summary,
  17. clickable,
  18. onClick: clickable ? () => undefined : undefined,
  19. }),
  20. );
  21. expect(html).toContain("text-foreground-subtle");
  22. expect(html).not.toMatch(/(?:^|\s)text-foreground(?:\s|$)/u);
  23. });
  24. });