From babc39c6a2a6be8635de55e7f5e6fe91ee44b974 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:48:09 +0200 Subject: [PATCH] Add test coverage --- tests/test_core/test_core_tohtml.py | 40 +++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/test_core/test_core_tohtml.py b/tests/test_core/test_core_tohtml.py index 9e150295..7974cef4 100644 --- a/tests/test_core/test_core_tohtml.py +++ b/tests/test_core/test_core_tohtml.py @@ -275,12 +275,12 @@ def testCoreToHtml_ConvertParagraphs(mockGUI): CONFIG.altDialogOpen = "::" CONFIG.altDialogClose = "::" html.setDialogueHighlight(True) - html._text = "## Chapter\n\nThis text :: has alt dialogue :: in it.\n\n" + html._text = "## Chapter\n\nThis text ::has alt dialogue:: in it.\n\n" html.tokenizeText() html.doConvert() assert html.result == ( "

Chapter

\n" - "

This text :: has alt dialogue :: in it.

\n" + "

This text ::has alt dialogue:: in it.

\n" ) # Footnotes @@ -308,6 +308,42 @@ def testCoreToHtml_ConvertParagraphs(mockGUI): ) +@pytest.mark.core +def testCoreToHtml_CloseTags(mockGUI): + """Test automatic closing of HTML tags for shortcodes.""" + project = NWProject() + html = ToHtml(project) + + html._isNovel = True + html._isFirst = True + + # Unclosed Shortcodes + html._text = "Text [b][i][s][u][m][sup][sub]text text text.\n" + html.tokenizeText() + html.doConvert() + assert html.result == ( + "

Text " + "text text text.

\n" + ) + + # Double Shortcodes + html._text = "Text [b][i][s][u][m][sup][sub]text [b][i][s][u][m][sup][sub]text text.\n" + html.tokenizeText() + html.doConvert() + assert html.result == ( + "

Text " + "text text text.

\n" + ) + + # Redundant Close Shortcodes + html._text = "Text text [/b][/i][/s][/u][/m][/sup][/sub]text text.\n" + html.tokenizeText() + html.doConvert() + assert html.result == ( + "

Text text text text.

\n" + ) + + @pytest.mark.core def testCoreToHtml_ConvertDirect(mockGUI): """Test the converter directly using the ToHtml class."""