import { test } from "node:test";
import assert from "node:assert/strict";
import { createElement } from "react";
import { renderToString } from "react-dom/server";
import { parseContentBlocks, extractToc } from "../dist/index.js";
import {
ArticleBody,
Toc,
ReadingProgress,
Lightbox,
CopyButton,
CodeBlock,
Chart,
VideoEmbed,
} from "../dist/react/index.js";
/**
* renderToString smoke tests WITH the optional peers installed (shiki and
* katex are devDependencies here). ArticleBody is an async server component:
* awaiting the component function yields a fully synchronous element tree
* that react-dom/server can render — the same contract Next.js RSC uses.
*/
const FULL_DOC = `
## Intro **section**
A paragraph with **bold**, *em*, \`code\`, a [link](https://example.com) and a ref[^1].
### Lists
- one
- **two**
1. first
2. second
#### Deep heading
---
> plain quote line
> [!TIP] Try this
> Callout body with a nested quote.
>> The pull quote itself.
>> — Someone




\`\`\`ts src/example.ts
const x: number = 1;
\`\`\`
\`\`\`mermaid
graph TD; A-->B
\`\`\`
\`\`\`chart
kind: bar
title: Signups
series Organic: Jan=10, Feb=20
series Paid: Jan=5, Feb=8
\`\`\`
\`\`\`stats
68 | essays
2 | stars
\`\`\`
$$e = mc^2$$
| Col A | Col B |
|-------|-------|
| a1 | b1 |
https://youtu.be/dQw4w9WgXcQ
[^1]: The footnote **definition**.
`;
test("ArticleBody renders every block type (peers present)", async () => {
const blocks = parseContentBlocks(FULL_DOC);
const html = renderToString(await ArticleBody({ blocks }));
// headings + ids
assert.match(html, /