summaryrefslogtreecommitdiff
path: root/src/test/kotlin/moe
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-02 16:05:38 +0200
committerLinnea Gräf <nea@nea.moe>2024-05-02 16:05:38 +0200
commit5316d761132a28df639eb70099c8af367f792733 (patch)
tree2a16543bb74216b7a853332bf7382dbfbaabcc5d /src/test/kotlin/moe
parent5f0552a7ea251a52fb89f7886f6a8dd48ce566d5 (diff)
downloadblog-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.kt101
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&lt;T extends ObjectControllerFactoryManager&lt;T&gt;&gt; {
-
- }</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&lt;T extends ObjectControllerFactoryManager&lt;T&gt;&gt; {
+ | 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