diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-07-27 18:53:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-27 18:53:23 +0200 |
commit | 26dde5b201b3c7e66212b07ddef333a3e340022a (patch) | |
tree | 7a63a244bcf2d9a8b0a031b9b7d82395634ba7fa /plugins/base/src/test/kotlin | |
parent | f4d2bf40e7b7e62aeb27bf0f1cabe53e35e68fd2 (diff) | |
download | dokka-26dde5b201b3c7e66212b07ddef333a3e340022a.tar.gz dokka-26dde5b201b3c7e66212b07ddef333a3e340022a.tar.bz2 dokka-26dde5b201b3c7e66212b07ddef333a3e340022a.zip |
Make current breadcrumb element not clickable and of default font color (#2588)
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r-- | plugins/base/src/test/kotlin/renderers/html/BreadcrumbsTest.kt | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/renderers/html/BreadcrumbsTest.kt b/plugins/base/src/test/kotlin/renderers/html/BreadcrumbsTest.kt new file mode 100644 index 00000000..bebc41dc --- /dev/null +++ b/plugins/base/src/test/kotlin/renderers/html/BreadcrumbsTest.kt @@ -0,0 +1,84 @@ +package renderers.html + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jsoup.nodes.Element +import org.junit.jupiter.api.Test +import signatures.renderedContent +import utils.* + +class BreadcrumbsTest : BaseAbstractTest() { + + private val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + + @Test + fun `should add breadcrumbs with current element`() { + val writerPlugin = TestOutputWriterPlugin() + testInline( + """ + |/src/main/kotlin/basic/TestClass.kt + |package testpackage + | + |class TestClass { + | fun foo() {} + |} + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("root/testpackage/-test-class/foo.html").selectBreadcrumbs().match( + link("root"), + delimiter(), + link("testpackage"), + delimiter(), + link("TestClass"), + delimiter(), + current("foo"), + ignoreSpanWithTokenStyle = true + ) + } + } + } + + @Test + fun `should mark only one element as current even if more elements have the same name`() { + val writerPlugin = TestOutputWriterPlugin() + testInline( + """ + |/src/main/kotlin/basic/TestClass.kt + |package testpackage + | + |class testname { + | val testname: String = "" + |} + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("root/testpackage/testname/testname.html").selectBreadcrumbs().match( + link("root"), + delimiter(), + link("testpackage"), + delimiter(), + link("testname"), + delimiter(), + current("testname"), + ignoreSpanWithTokenStyle = true + ) + } + } + } + + private fun Element.selectBreadcrumbs() = this.select("div.breadcrumbs").single() + + private fun link(text: String): Tag = A(text) + private fun delimiter(): Tag = Span().withClasses("delimiter") + private fun current(text: String): Tag = Span(text).withClasses("current") +} |