diff --git a/glazed-donut.Tests/MarkdownParserTests.cs b/glazed-donut.Tests/MarkdownParserTests.cs index 8099b1a..a116da2 100644 --- a/glazed-donut.Tests/MarkdownParserTests.cs +++ b/glazed-donut.Tests/MarkdownParserTests.cs @@ -49,5 +49,55 @@ public void ReturnHtmlString_WhenParagraphIsValid(string input, string expectedH new object[] { "# Markdown", "

Markdown

\n" }, new object[] { "---", "
" } }; + + [Theory] + [InlineData("#")] + [InlineData("#\n")] + [InlineData("# ")] + [InlineData("# \n")] + public void ReturnEmptyHeaderElement_WhenHeaderTextIsEmpty(string input) + { + var stream = new MemoryStream(Encoding.UTF8.GetBytes(input)); + var parser = new MarkdownParser(stream); + + var htmlString = parser.Parse(); + + Assert.Equal("

\n", htmlString); + } + + [Theory] + [InlineData("# header #")] + [InlineData("# header #\n")] + [InlineData("# header ##")] + [InlineData("# header ##\n")] + public void ReturnNormalHeaderElement_WhenHeaderTextFollowedByHashtags(string input) + { + var stream = new MemoryStream(Encoding.UTF8.GetBytes(input)); + var parser = new MarkdownParser(stream); + + var htmlString = parser.Parse(); + + Assert.Equal("

header

\n", htmlString); + } + + [Theory, MemberData(nameof(HeaderTextWithImmediateHashtags))] + public void ReturnHeaderElementWithHashtags_WhenHeaderTextImmediatelyFollowedByHashtags(string input, string expectedHtmlString) + { + var stream = new MemoryStream(Encoding.UTF8.GetBytes(input)); + var parser = new MarkdownParser(stream); + + var htmlString = parser.Parse(); + + Assert.Equal(expectedHtmlString, htmlString); + } + + public static IEnumerable HeaderTextWithImmediateHashtags => + new List + { + new object[] { "# header#", "

header#

\n" }, + new object[] { "# header#\n", "

header#

\n" }, + new object[] { "# header##", "

header##

\n" }, + new object[] { "# header##\n", "

header##

\n" } + }; } }