diff --git a/Elternbeirat.Web.Tests/MarkdownTests.cs b/Elternbeirat.Web.Tests/MarkdownTests.cs new file mode 100644 index 0000000..038f9ca --- /dev/null +++ b/Elternbeirat.Web.Tests/MarkdownTests.cs @@ -0,0 +1,81 @@ +using Elternbeirat.Web.Shared; + +namespace Elternbeirat.Web.Tests; + +/// +/// Unit tests for the Markdown pipeline behind every editor-written body. Pure logic, +/// no PocketBase needed. +/// +public class MarkdownTests +{ + [Theory] + [InlineData(null)] + [InlineData("")] + public void Empty_input_renders_nothing(string? markdown) => + Markdown.ToHtml(markdown).ShouldBe(""); + + [Fact] + public void Custom_container_renders_a_div_with_its_name_as_class() + { + var html = Markdown.ToHtml("::: kennzahlen\n- **seit 1975** Gründung\n:::"); + + html.ShouldContain("
"); + html.ShouldContain("seit 1975"); + } + + [Fact] + public void Unknown_container_renders_its_content_as_normal_text() + { + // A typo in the block name must cost the styling, never the text. + var html = Markdown.ToHtml("::: gibtsnicht\nNormaler Text.\n:::"); + + html.ShouldContain("

Normaler Text.

"); + html.ShouldNotContain(":::"); + } + + [Fact] + public void Raw_html_is_escaped_not_passed_through() + { + // The body is rendered as a MarkupString; a passed-through \n\n
Box
"); + + html.ShouldNotContain("