mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add tests for clicking on a link when markdown is from a string
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
This commit is contained in:
@@ -7,7 +7,7 @@ from textual.geometry import Offset
|
||||
from textual.widgets import Markdown, MarkdownViewer
|
||||
|
||||
|
||||
class MarkdownViewerApp(App[None]):
|
||||
class MarkdownFileViewerApp(App[None]):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield MarkdownViewer()
|
||||
|
||||
@@ -17,9 +17,29 @@ class MarkdownViewerApp(App[None]):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("link", [0, 1, 2])
|
||||
async def test_markdown_viewer_anchor_link(link: int) -> None:
|
||||
async def test_markdown_file_viewer_anchor_link(link: int) -> None:
|
||||
"""Test https://github.com/Textualize/textual/issues/3094"""
|
||||
async with MarkdownViewerApp().run_test() as pilot:
|
||||
async with MarkdownFileViewerApp().run_test() as pilot:
|
||||
# There's not really anything to test *for* here, but the lack of an
|
||||
# exception is the win (before the fix this is testing it would have
|
||||
# been FileNotFoundError).
|
||||
await pilot.click(Markdown, Offset(2, link))
|
||||
|
||||
|
||||
class MarkdownStringViewerApp(App[None]):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield MarkdownViewer(Path(__file__).with_suffix(".md").read_text())
|
||||
|
||||
async def on_mount(self) -> None:
|
||||
self.query_one(MarkdownViewer).show_table_of_contents = False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("link", [0, 1, 2])
|
||||
async def test_markdown_string_viewer_anchor_link(link: int) -> None:
|
||||
"""Test https://github.com/Textualize/textual/issues/3094
|
||||
|
||||
Also https://github.com/Textualize/textual/pull/3244#issuecomment-1710278718."""
|
||||
async with MarkdownStringViewerApp().run_test() as pilot:
|
||||
# There's not really anything to test *for* here, but the lack of an
|
||||
# exception is the win (before the fix this is testing it would have
|
||||
# been FileNotFoundError).
|
||||
|
||||
Reference in New Issue
Block a user