2026-07-26 18:52:25 +02:00
|
|
|
import { describe, expect, test } from 'bun:test';
|
2026-08-28 02:08:09 +03:00
|
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
2026-07-26 18:52:25 +02:00
|
|
|
|
|
|
|
|
import { QuestionMarkdown } from './QuestionMarkdown';
|
|
|
|
|
|
2026-08-28 02:08:09 +03:00
|
|
|
// The markdown renderer is lazy, so a synchronous server render always emits the
|
|
|
|
|
// Suspense fallback QuestionMarkdown supplies. That fallback is the surface that
|
|
|
|
|
// has to keep the exact question text and the question typography classes.
|
2026-07-26 18:52:25 +02:00
|
|
|
describe('QuestionMarkdown', () => {
|
2026-08-28 02:08:09 +03:00
|
|
|
test('renders the question content verbatim', () => {
|
2026-07-26 18:52:25 +02:00
|
|
|
const content = 'Choose **one** from `mode`: [details](https://example.com)';
|
|
|
|
|
|
2026-08-28 02:08:09 +03:00
|
|
|
const html = renderToStaticMarkup(<QuestionMarkdown content={content} size="meta" />);
|
|
|
|
|
|
|
|
|
|
expect(html).toBe(
|
|
|
|
|
`<div class="question-markdown typography-meta whitespace-pre-wrap">${content}</div>`,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('applies meta typography and caller classes', () => {
|
|
|
|
|
const html = renderToStaticMarkup(
|
|
|
|
|
<QuestionMarkdown content="Meta" size="meta" className="font-medium text-foreground" />,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(html).toContain('class="question-markdown typography-meta font-medium text-foreground whitespace-pre-wrap"');
|
2026-07-26 18:52:25 +02:00
|
|
|
});
|
|
|
|
|
|
2026-08-28 02:08:09 +03:00
|
|
|
test('applies micro typography and caller classes', () => {
|
|
|
|
|
const html = renderToStaticMarkup(
|
|
|
|
|
<QuestionMarkdown content="Micro" size="micro" className="text-muted-foreground" />,
|
|
|
|
|
);
|
2026-07-26 18:52:25 +02:00
|
|
|
|
2026-08-28 02:08:09 +03:00
|
|
|
expect(html).toContain('class="question-markdown typography-micro text-muted-foreground whitespace-pre-wrap"');
|
2026-07-26 18:52:25 +02:00
|
|
|
});
|
|
|
|
|
});
|