/
JavadocAccessorNamingTest.kt
80 lines (70 loc) · 2.49 KB
/
JavadocAccessorNamingTest.kt
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
package org.jetbrains.dokka.javadoc
import org.jsoup.Jsoup
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
import utils.*
internal class JavadocAccessorNamingTest : AbstractJavadocTemplateMapTest() {
val configuration = dokkaConfiguration {
suppressObviousFunctions = true
sourceSets {
sourceSet {
sourceRoots = listOf("src/main/kotlin")
}
}
}
/**
* This is a quick sanity check for the AccessorMethodNamingTest
*/
@Test
fun verifySpecialIsRuleIsApplied() {
val writerPlugin = TestOutputWriterPlugin()
testInline(
"""
/src/main/kotlin/sample/TestCase.kt
package sample
/**
* Test links:
* - [TestCase.issuesFetched]
* - [TestCase.isFoo]
*/
data class TestCase(
var issuesFetched: Int,
var isFoo: String,
)
""".trimIndent(),
configuration,
cleanupOutput = false,
pluginOverrides = listOf(writerPlugin, JavadocPlugin())
) {
renderingStage = { _, _ ->
val html = writerPlugin.writer.contents.getValue("sample/TestCase.html").let { Jsoup.parse(it) }
val props = html
.select("#memberSummary_tabpanel")
.select("th[scope=row].colSecond")
.select("code")
.map { it.text() }
.toSet()
assertEquals(setOf(
"getIssuesFetched()",
"setIssuesFetched(Integer issuesFetched)",
"isFoo()",
"setFoo(String isFoo)",
), props)
val descriptionLinks = html
.select("div.description")
.select("p")
.select("a")
.eachAttr("href")
.map { a -> a.takeLastWhile { it != '#' } }
assertEquals(setOf(
"issuesFetched",
"isFoo()",
), descriptionLinks.toSet())
// Make sure that the ids from above actually exist
assertEquals(1, html.select("[id = isFoo()]").size)
// Bug! Nothing in the doc has the right id
assertEquals(0, html.select("[id = issuesFetched]").size)
}
}
}
}