aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt20
-rw-r--r--plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt32
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt14
-rw-r--r--plugins/base/src/test/kotlin/utils/TestUtils.kt11
4 files changed, 73 insertions, 4 deletions
diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
index 7e11dc85..3531f148 100644
--- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
+++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
@@ -7,10 +7,8 @@ import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.model.doc.DocumentationNode
import org.jetbrains.dokka.model.doc.Param
import org.jetbrains.dokka.model.doc.Text
-import org.jetbrains.dokka.pages.ContentDRILink
-import org.jetbrains.dokka.pages.ContentPage
-import org.jetbrains.dokka.pages.MemberPageNode
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.pages.*
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import org.junit.jupiter.api.Test
import utils.*
@@ -1057,6 +1055,10 @@ class ContentForParamsTest : BaseAbstractTest() {
table {
group {
+"abc"
+ check {
+ val textStyles = children.single { it is ContentText }.style
+ assertContains(textStyles, TextStyle.Underlined)
+ }
group { group { +"comment to param" } }
}
}
@@ -1110,14 +1112,26 @@ class ContentForParamsTest : BaseAbstractTest() {
table {
group {
+"first"
+ check {
+ val textStyles = children.single { it is ContentText }.style
+ assertContains(textStyles, TextStyle.Underlined)
+ }
group { group { +"comment to first param" } }
}
group {
+"second"
+ check {
+ val textStyles = children.single { it is ContentText }.style
+ assertContains(textStyles, TextStyle.Underlined)
+ }
group { group { +"comment to second param" } }
}
group {
+"third"
+ check {
+ val textStyles = children.single { it is ContentText }.style
+ assertContains(textStyles, TextStyle.Underlined)
+ }
group { group { +"comment to third param" } }
}
}
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index f7911c08..b2397b95 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -436,6 +436,38 @@ class JavadocParserTest : BaseAbstractTest() {
}
@Test
+ fun `u tag is handled properly`() {
+ val source = """
+ |/src/main/kotlin/test/Test.java
+ |package example
+ |
+ | /**
+ | * An example of using u tag: <u>underlined</u>
+ | */
+ | public class Test {}
+ """.trimIndent()
+ testInline(
+ source,
+ configuration,
+ ) {
+ documentablesCreationStage = { modules ->
+ val docs = modules.first().packages.first().classlikes.single().documentation.first().value
+ val root = docs.children.first().root
+
+ assertEquals(
+ listOf(
+ P(children = listOf(
+ Text("An example of using u tag: "),
+ U(children = listOf(Text("underlined"))),
+ )),
+ ),
+ root.children
+ )
+ }
+ }
+ }
+
+ @Test
fun `undocumented see also from java`(){
testInline(
"""
diff --git a/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt b/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
index 98f73ffa..507f1779 100644
--- a/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
@@ -92,6 +92,18 @@ class TextStylesTest : HtmlRenderingOnlyTestBase() {
renderedContent.match(Var("variable"))
}
+ @Test
+ fun `should include underlined text`() {
+ val page = testPage {
+ group(styles = setOf(TextStyle.Underlined)) {
+ text("underlined text")
+ }
+ }
+ HtmlRenderer(context).render(page)
+ println(renderedContent)
+ renderedContent.match(U("underlined text"))
+ }
+
override val renderedContent: Element
get() = files.contents.getValue("test-page.html").let { Jsoup.parse(it) }.select("#content").single()
-} \ No newline at end of file
+}
diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt
index e4bc4a1e..8cb126d5 100644
--- a/plugins/base/src/test/kotlin/utils/TestUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt
@@ -7,6 +7,7 @@ import org.jetbrains.dokka.model.doc.P
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import kotlin.collections.orEmpty
+import kotlin.test.asserter
@DslMarker
annotation class TestDSL
@@ -38,6 +39,16 @@ interface AssertDSL {
assert(count() == n) { "${prefix}Expected $n, got ${count()}" }
}
+/*
+ * TODO replace with kotlin.test.assertContains after migrating to Kotlin 1.5+
+ */
+internal fun <T> assertContains(iterable: Iterable<T>, element: T, ) {
+ asserter.assertTrue(
+ { "Expected the collection to contain the element.\nCollection <$iterable>, element <$element>." },
+ iterable.contains(element)
+ )
+}
+
inline fun <reified T : Any> Any?.assertIsInstance(name: String): T =
this.let { it as? T } ?: throw AssertionError("$name should not be null")