blob: c77a78fb2e2f15a103879a730ddc6368ec64a916 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package renderers.html
import junit.framework.Assert.assertEquals
import kotlinx.html.body
import kotlinx.html.html
import kotlinx.html.stream.createHTML
import org.jetbrains.dokka.base.renderers.html.buildBreakableText
import org.junit.jupiter.api.Test
class FormattingUtilsTest {
@Test
fun `should build breakable text`(){
val testedText = "kotlinx.collections.immutable"
val expectedHtml = """
<html>
<body><span>kotlinx.</span><wbr></wbr><span>collections.</span><wbr></wbr><span>immutable</span></body>
</html>
""".trimIndent()
val html = createHTML(prettyPrint = true).html {
body {
buildBreakableText(testedText)
}
}
assertEquals(expectedHtml.trim(), html.trim())
}
@Test
fun `should build breakable text without empty spans`(){
val testedText = "Package org.jetbrains.dokka.it.moduleC"
val expectedHtml = """
<html>
<body><span><span>Package</span></span> <span>org.</span><wbr></wbr><span>jetbrains.</span><wbr></wbr><span>dokka.</span><wbr></wbr><span>it.</span><wbr></wbr><span>moduleC</span></body>
</html>
""".trimIndent()
val html = createHTML(prettyPrint = true).html {
body {
buildBreakableText(testedText)
}
}
assertEquals(expectedHtml.trim(), html.trim())
}
@Test
fun `should build breakable text for text with braces`(){
val testedText = "[Common]kotlinx.collections.immutable"
val expectedHtml = """
<html>
<body><span>[Common]kotlinx.</span><wbr></wbr><span>collections.</span><wbr></wbr><span>immutable</span></body>
</html>
""".trimIndent()
val html = createHTML(prettyPrint = true).html {
body {
buildBreakableText(testedText)
}
}
assertEquals(expectedHtml.trim(), html.trim())
}
@Test
fun `should build breakable text for camel case notation`(){
val testedText = "DokkkkkkkaIsTheBest"
val expectedHtml = """
<html>
<body><span>Dokkkkkkka</span><wbr></wbr><span>Is</span><wbr></wbr><span>The</span><wbr></wbr><span><span>Best</span></span></body>
</html>
""".trimIndent()
val html = createHTML(prettyPrint = true).html {
body {
buildBreakableText(testedText)
}
}
assertEquals(expectedHtml.trim(), html.trim())
}
}
|