From 5316d761132a28df639eb70099c8af367f792733 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 2 May 2024 16:05:38 +0200 Subject: Split up html generation --- src/test/kotlin/moe/nea/blog/gen/HtmlTest.kt | 101 ++++++++++++++------------- 1 file changed, 54 insertions(+), 47 deletions(-) (limited to 'src/test/kotlin/moe') 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( - """ -

Hello World

lol hehe

public class ObjectControllerFactoryManagerProvider<T extends ObjectControllerFactoryManager<T>> {
-                    
-                }
- """.trimIndent(), - """ - # Hello World - - ***lol* hehe** - - ```java - public class ObjectControllerFactoryManagerProvider> { - - } - ``` - """.trimIndent() - ) - } - - @Test - fun testBold() { - assertGenerator("Hii", Bold(Word("Hii"))) - } - - @Test - fun testParagraphs() { - assertGenerator( - "

Test Whatever

", - 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( + """ + |

Hello World

lol hehe

public class ObjectControllerFactoryManagerProvider<T extends ObjectControllerFactoryManager<T>> {
+			|   public ObjectControllerFactoryManagerProvider() {}
+			|}
+ """.trimMargin(), + """ + |# Hello World + | + |***lol* hehe** + | + |```java + |public class ObjectControllerFactoryManagerProvider> { + | public ObjectControllerFactoryManagerProvider() {} + |} + |``` + """.trimMargin() + ) + } + + @Test + fun testBold() { + assertGenerator("Hii", Bold(Word("Hii"))) + } + + @Test + fun testParagraphs() { + assertGenerator( + "

Test Whatever

", + Paragraph(FormatSequence(Word("Test"), Whitespace(), Bold(Word("Whatever")))) + ) + } } \ No newline at end of file -- cgit