aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/renderers/html
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-08-18 19:33:53 +0200
committerGitHub <noreply@github.com>2022-08-18 19:33:53 +0200
commit50a3323322265ff3b5dab1d861a25bbb1167812a (patch)
tree0966cfab6d9155724a65439a5c0d1476d66b0a7a /plugins/base/src/test/kotlin/renderers/html
parentdf8d9879b818799c83ff731b3a78e7d2b96fd8e5 (diff)
downloaddokka-50a3323322265ff3b5dab1d861a25bbb1167812a.tar.gz
dokka-50a3323322265ff3b5dab1d861a25bbb1167812a.tar.bz2
dokka-50a3323322265ff3b5dab1d861a25bbb1167812a.zip
Add deprecation details block (#2622)
Diffstat (limited to 'plugins/base/src/test/kotlin/renderers/html')
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/NavigationTest.kt109
1 files changed, 108 insertions, 1 deletions
diff --git a/plugins/base/src/test/kotlin/renderers/html/NavigationTest.kt b/plugins/base/src/test/kotlin/renderers/html/NavigationTest.kt
index 104246cb..13a9e711 100644
--- a/plugins/base/src/test/kotlin/renderers/html/NavigationTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/NavigationTest.kt
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test
import utils.TestOutputWriterPlugin
import kotlin.test.assertEquals
import utils.navigationHtml
+import kotlin.test.assertNull
class NavigationTest : BaseAbstractTest() {
@@ -19,6 +20,106 @@ class NavigationTest : BaseAbstractTest() {
}
@Test
+ fun `should strike deprecated class link`() {
+ val writerPlugin = TestOutputWriterPlugin()
+ testInline(
+ """
+ |/src/main/kotlin/com/example/SimpleDeprecatedClass.kt
+ |package com.example
+ |
+ |@Deprecated("reason")
+ |class SimpleDeprecatedClass {}
+ """.trimIndent(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val content = writerPlugin.writer.navigationHtml().select("div.sideMenuPart")
+ assertEquals(3, content.size)
+
+ // Navigation menu should be the following:
+ // - root
+ // - com.example
+ // - SimpleDeprecatedClass
+
+ content[0].assertNavigationLink(
+ id = "root-nav-submenu",
+ text = "root",
+ address = "index.html",
+ )
+
+ content[1].assertNavigationLink(
+ id = "root-nav-submenu-0",
+ text = "com.example",
+ address = "root/com.example/index.html",
+ )
+
+ content[2].assertNavigationLink(
+ id = "root-nav-submenu-0-0",
+ text = "SimpleDeprecatedClass",
+ address = "root/com.example/-simple-deprecated-class/index.html",
+ icon = NavigationNodeIcon.CLASS_KT,
+ isStrikethrough = true
+ )
+ }
+ }
+ }
+
+ @Test
+ fun `should not strike pages where only one of N documentables is deprecated`() {
+ val writerPlugin = TestOutputWriterPlugin()
+ testInline(
+ """
+ |/src/main/kotlin/com/example/File.kt
+ |package com.example
+ |
+ |/**
+ | * First
+ | */
+ |@Deprecated("reason")
+ |fun functionWithCommonName()
+ |
+ |/**
+ | * Second
+ | */
+ |fun functionWithCommonName()
+ """.trimIndent(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val content = writerPlugin.writer.navigationHtml().select("div.sideMenuPart")
+ assertEquals(3, content.size)
+
+ // Navigation menu should be the following:
+ // - root
+ // - com.example
+ // - functionWithCommonName
+
+ content[0].assertNavigationLink(
+ id = "root-nav-submenu",
+ text = "root",
+ address = "index.html",
+ )
+
+ content[1].assertNavigationLink(
+ id = "root-nav-submenu-0",
+ text = "com.example",
+ address = "root/com.example/index.html",
+ )
+
+ content[2].assertNavigationLink(
+ id = "root-nav-submenu-0-0",
+ text = "functionWithCommonName()",
+ address = "root/com.example/function-with-common-name.html",
+ icon = NavigationNodeIcon.FUNCTION,
+ isStrikethrough = false
+ )
+ }
+ }
+ }
+
+ @Test
fun `should have expandable classlikes`() {
val writerPlugin = TestOutputWriterPlugin()
testInline(
@@ -209,7 +310,7 @@ class NavigationTest : BaseAbstractTest() {
}
private fun Element.assertNavigationLink(
- id: String, text: String, address: String, icon: NavigationNodeIcon? = null
+ id: String, text: String, address: String, icon: NavigationNodeIcon? = null, isStrikethrough: Boolean = false
) {
assertEquals(id, this.id())
@@ -224,5 +325,11 @@ class NavigationTest : BaseAbstractTest() {
assertEquals("nav-link-child", iconStyles[0])
assertEquals(icon.style(), "${iconStyles[1]} ${iconStyles[2]}")
}
+ if (isStrikethrough) {
+ val textInsideStrikethrough = link.selectFirst("strike")?.text()
+ assertEquals(text, textInsideStrikethrough)
+ } else {
+ assertNull(link.selectFirst("strike"))
+ }
}
}