test(21-02): add failing tests for ChatMarkdownMessage and ChatCodeBlock

This commit is contained in:
Nexus Dev 2026-04-01 16:38:13 +00:00
parent d94879e85b
commit df44e1eef7

View file

@ -1,17 +1,39 @@
// @vitest-environment node // @vitest-environment node
import { describe, it } from "vitest";
import { describe, expect, it } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import { ChatMarkdownMessage } from "./ChatMarkdownMessage";
describe("ChatMarkdownMessage", () => { describe("ChatMarkdownMessage", () => {
describe("markdown rendering (CHAT-02)", () => { it("renders plain text as a paragraph", () => {
it.todo("renders plain text as paragraph"); const html = renderToStaticMarkup(
it.todo("renders code blocks with hljs classes for syntax highlighting"); <ChatMarkdownMessage content="Hello world" />,
it.todo("renders GFM tables"); );
it.todo("renders headings, lists, and links"); expect(html).toContain("<p>");
expect(html).toContain("Hello world");
}); });
describe("code block features (CHAT-03)", () => { it("renders fenced code blocks with hljs classes applied by rehype-highlight", () => {
it.todo("renders language label from code fence"); const content = "```typescript\nconst x: number = 42;\n```";
it.todo("renders copy button with aria-label"); const html = renderToStaticMarkup(
it.todo("extracts code text content for clipboard"); <ChatMarkdownMessage content={content} />,
);
expect(html).toContain("hljs");
});
it("renders a copy button with aria-label='Copy code'", () => {
const content = "```typescript\nconst x = 1;\n```";
const html = renderToStaticMarkup(
<ChatMarkdownMessage content={content} />,
);
expect(html).toContain('aria-label="Copy code"');
});
it("renders a language label extracted from the code fence", () => {
const content = "```typescript\nconst x = 1;\n```";
const html = renderToStaticMarkup(
<ChatMarkdownMessage content={content} />,
);
expect(html).toContain("typescript");
}); });
}); });