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