1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import { render, screen, waitFor } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { AsciiDocView } from "./AsciiDocView";
// Deliberately NOT mocked: this exercises the real @asciidoctor/core module
// resolution and conversion — the exact integration that once broke in
// production while every mocked test stayed green.
describe("AsciiDocView (real converter)", () => {
it("renders a document with title, section and list", async () => {
render(
<AsciiDocView
content={
"= The Title\n\n== Section\n\n* item one\n* item two\n\nSome *bold* text."
}
/>,
);
await waitFor(() => expect(screen.getByText("The Title")).toBeDefined(), {
timeout: 15000,
});
expect(screen.getByText("Section")).toBeDefined();
expect(screen.getByText("item one")).toBeDefined();
expect(screen.getByText("bold")).toBeDefined();
}, 20000);
it("re-renders when the content changes", async () => {
const { rerender } = render(<AsciiDocView content="= First" />);
await waitFor(() => expect(screen.getByText("First")).toBeDefined(), {
timeout: 15000,
});
rerender(<AsciiDocView content="= Second" />);
await waitFor(() => expect(screen.getByText("Second")).toBeDefined());
}, 20000);
});
|