from typing import Any, Callable, Optional, Tuple
import pytest
from aiogram.utils.markdown import (
blockquote,
bold,
code,
hblockquote,
hbold,
hcode,
hide_link,
hitalic,
hlink,
hpre,
hstrikethrough,
hunderline,
italic,
link,
pre,
strikethrough,
text,
underline,
)
class TestMarkdown:
@pytest.mark.parametrize(
"func,args,sep,result",
[
[text, ("test", "test"), " ", "test test"],
[text, ("test", "test"), "\n", "test\ntest"],
[text, ("test", "test"), None, "test test"],
[bold, ("test", "test"), " ", "*test test*"],
[hbold, ("test", "test"), " ", "test test"],
[italic, ("test", "test"), " ", "_\rtest test_\r"],
[hitalic, ("test", "test"), " ", "test test"],
[code, ("test", "test"), " ", "`test test`"],
[hcode, ("test", "test"), " ", "test test"],
[pre, ("test", "test"), " ", "```\ntest test\n```"],
[hpre, ("test", "test"), " ", "
test test"], [underline, ("test", "test"), " ", "__\rtest test__\r"], [hunderline, ("test", "test"), " ", "test test"], [strikethrough, ("test", "test"), " ", "~test test~"], [hstrikethrough, ("test", "test"), " ", "
spam eggs"], pytest.param( hblockquote, ("spam", "eggs"), "\n", "
spam\neggs", id="HTML blockquote multiline", ), ], ) def test_formatter( self, func: Callable[[Any], Any], args: Tuple[str], sep: Optional[str], result: str ): assert func(*args, **({"sep": sep} if sep is not None else {})) == result # type: ignore