import { expect, test } from "bun:test";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { MessageMarkdown } from "./markdown";
let PARTICIPANT_MESSAGE = [
"**Bold** and *italic* with [the docs](https://example.com).",
"",
"- first",
"- second",
"",
"1. one",
"2. two",
"",
"> quoted",
"",
"Use `bun test`.",
"",
"```ts",
"let answer = 42;",
"```",
"",
"# Ordinary message text",
"",
"",
'
',
].join("\n");
function markdown(source: string): string {
return renderToStaticMarkup(createElement(MessageMarkdown, { source }));
}
test("conversation Markdown admits formatting without document features", () => {
let markup = markdown(PARTICIPANT_MESSAGE);
expect(markup).toContain("Bold");
expect(markup).toContain("italic");
expect(markup).toContain("
"); expect(markup).toContain("quoted"); expect(markup).toContain('href="https://example.com"'); expect(markup).toContain('target="_blank"'); expect(markup).toContain("Use
"); expect(markup).toContain('bun test.let answer = 42;'); expect(markup).toContain("Ordinary message text"); expect(markup).not.toContain(""); expect(markup).not.toContain("
strongly"); });