blob: 07c5a2402379d9d356b939447daf0d852ee816a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package moe.nea.blog.gen
import moe.nea.blog.md.*
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"))))
)
}
}
|