diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-02 16:05:38 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-05-02 16:05:38 +0200 |
commit | 5316d761132a28df639eb70099c8af367f792733 (patch) | |
tree | 2a16543bb74216b7a853332bf7382dbfbaabcc5d /src/test/kotlin/moe | |
parent | 5f0552a7ea251a52fb89f7886f6a8dd48ce566d5 (diff) | |
download | blog-infra-5316d761132a28df639eb70099c8af367f792733.tar.gz blog-infra-5316d761132a28df639eb70099c8af367f792733.tar.bz2 blog-infra-5316d761132a28df639eb70099c8af367f792733.zip |
Split up html generation
Diffstat (limited to 'src/test/kotlin/moe')
-rw-r--r-- | src/test/kotlin/moe/nea/blog/gen/HtmlTest.kt | 101 |
1 files changed, 54 insertions, 47 deletions
diff --git a/src/test/kotlin/moe/nea/blog/gen/HtmlTest.kt b/src/test/kotlin/moe/nea/blog/gen/HtmlTest.kt index 07c5a24..4b76a5f 100644 --- a/src/test/kotlin/moe/nea/blog/gen/HtmlTest.kt +++ b/src/test/kotlin/moe/nea/blog/gen/HtmlTest.kt @@ -1,56 +1,63 @@ package moe.nea.blog.gen -import moe.nea.blog.md.* +import moe.nea.blog.md.Bold +import moe.nea.blog.md.FormatSequence +import moe.nea.blog.md.MarkdownElement +import moe.nea.blog.md.MarkdownParser +import moe.nea.blog.md.Paragraph +import moe.nea.blog.md.Whitespace +import moe.nea.blog.md.Word import kotlin.test.Test import kotlin.test.assertEquals class HtmlTest { - fun assertGenerator(generatedHtml: String, markdown: MarkdownElement) { - val generator = HtmlGenerator() - generator.registerDefaultGenerators() - assertEquals(generatedHtml, generator.generateHtml(markdown).text) - } - - fun assertGeneratorMD(generatedHtml: String, text: String) { - val generator = HtmlGenerator() - generator.registerDefaultGenerators() - assertEquals(generatedHtml, generator.generateHtml(MarkdownParser(text).also { it.addDefaultParsers() }.readDocument()).text) - } - - @Test - fun testBiggerFile() { - assertGeneratorMD( - """ - <h1>Hello World</h1><p></p><p><b><em>lol</em> hehe</b></p><pre><code class="language-java">public class ObjectControllerFactoryManagerProvider<T extends ObjectControllerFactoryManager<T>> { - - }</code></pre> - """.trimIndent(), - """ - # Hello World - - ***lol* hehe** - - ```java - public class ObjectControllerFactoryManagerProvider<T extends ObjectControllerFactoryManager<T>> { - - } - ``` - """.trimIndent() - ) - } - - @Test - fun testBold() { - assertGenerator("<b>Hii</b>", Bold(Word("Hii"))) - } - - @Test - fun testParagraphs() { - assertGenerator( - "<p>Test <b>Whatever</b></p>", - Paragraph(FormatSequence(Word("Test"), Whitespace(), Bold(Word("Whatever")))) - ) - } + fun assertGenerator(generatedHtml: String, markdown: MarkdownElement) { + val generator = MD2HtmlGenerator() + generator.registerDefaultGenerators() + assertEquals(generatedHtml, generator.generateHtml(markdown).text) + } + + fun assertGeneratorMD(generatedHtml: String, text: String) { + val generator = MD2HtmlGenerator() + generator.registerDefaultGenerators() + assertEquals(generatedHtml, + generator.generateHtml(MarkdownParser(text).also { it.addDefaultParsers() }.readDocument()).text) + } + + @Test + fun testBiggerFile() { + assertGeneratorMD( + """ + |<h1>Hello World</h1><p></p><p><b><em>lol</em> hehe</b></p><pre><code class="language-java">public class ObjectControllerFactoryManagerProvider<T extends ObjectControllerFactoryManager<T>> { + | public ObjectControllerFactoryManagerProvider() {} + |}</code></pre> + """.trimMargin(), + """ + |# Hello World + | + |***lol* hehe** + | + |```java + |public class ObjectControllerFactoryManagerProvider<T extends ObjectControllerFactoryManager<T>> { + | public ObjectControllerFactoryManagerProvider() {} + |} + |``` + """.trimMargin() + ) + } + + @Test + fun testBold() { + assertGenerator("<b>Hii</b>", Bold(Word("Hii"))) + } + + @Test + fun testParagraphs() { + assertGenerator( + "<p>Test <b>Whatever</b></p>", + Paragraph(FormatSequence(Word("Test"), Whitespace(), Bold(Word("Whatever")))) + ) + } }
\ No newline at end of file |