from discord_rss_bot.markdown import convert_html_to_md def test_convert_to_md() -> None: # Test bold assert convert_html_to_md("bold") == "**bold**" # Test italic assert convert_html_to_md("italic") == "*italic*" # Test blockquote assert convert_html_to_md("
blockquote
") == ">>> blockquote" # Test code assert convert_html_to_md("code") == "`code`" # Test strikethrough assert convert_html_to_md("strikethrough") == "~~strikethrough~~" # Test link assert convert_html_to_md('link') == "[link](https://example.com)" # Test pre code assert convert_html_to_md("
pre code
") == "``pre code``" # Test strong assert convert_html_to_md("strong") == "**strong**" # Test multiple tags assert ( convert_html_to_md('bold italic link code strikethrough') # noqa: E501 == "**bold** *italic* [link](https://example.com) `code` ~~strikethrough~~" ) # Test removing all other tags assert convert_html_to_md("

paragraph

") == "paragraph" assert convert_html_to_md("

paragraph

paragraph

") == "paragraph\nparagraph" # Test
tags assert convert_html_to_md("

paragraph
paragraph

") == "paragraph\nparagraph" # Test removing trailing newline assert convert_html_to_md("paragraph ") == "paragraph" # Test removing leading and trailing whitespace assert convert_html_to_md(" paragraph ") == "paragraph" # Test removing leading and trailing whitespace and trailing newline assert convert_html_to_md(" paragraph\n \n") == "paragraph" # Test real entry nvidia_entry: str = ( '

' "NVIDIA Broadcast 1.4 Adds Eye Contact and Vignette Effects With Virtual Background Enhancements

" '
' '
Plus new options to mirror your camera and take a selfie.
' # noqa: E501 '
' '
' # noqa: E501 ) assert ( convert_html_to_md(nvidia_entry) == "[NVIDIA Broadcast 1.4 Adds Eye Contact and Vignette Effects With Virtual Background Enhancements](https://www.nvidia.com/en-us/geforce/news/jan-2023-nvidia-broadcast-update/)\n" # noqa: E501 "Plus new options to mirror your camera and take a selfie.[https://www.nvidia.com/en-us/geforce/news/jan-2023-nvidia-broadcast-update/](https://www.nvidia.com/en-us/geforce/news/jan-2023-nvidia-broadcast-update/)" # noqa: E501 )