diff options
author | Denis Ambatenne <75973078+d-ambatenne@users.noreply.github.com> | 2023-07-06 14:46:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 14:46:12 +0200 |
commit | c075c9570777d0946ba48ad88171379b52733416 (patch) | |
tree | a78872456b7248e2b1d0e5d716578d5a6aacc4ab /plugins/base/src/test | |
parent | 9559158bfeeb274e9ccf1b4563f1b23b42afc493 (diff) | |
download | dokka-c075c9570777d0946ba48ad88171379b52733416.tar.gz dokka-c075c9570777d0946ba48ad88171379b52733416.tar.bz2 dokka-c075c9570777d0946ba48ad88171379b52733416.zip |
HTML: fix of redundant dot and related autotest (#2289) (#3057)
* HTML: fix of redundant dot and related autotest (#2289)
* Update plugins/base/src/test/kotlin/renderers/html/SearchbarDataInstallerTest.kt
Change after the PR #3057 review
Co-authored-by: Ignat Beresnev <ignat.beresnev@jetbrains.com>
* Change after the PR #3057 review
Co-authored-by: Ignat Beresnev <ignat.beresnev@jetbrains.com>
---------
Co-authored-by: Denis Ambatenne <denis.ambatenne@jetbrains.com>
Co-authored-by: Ignat Beresnev <ignat.beresnev@jetbrains.com>
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r-- | plugins/base/src/test/kotlin/renderers/html/SearchbarDataInstallerTest.kt | 46 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/utils/HtmlUtils.kt | 5 |
2 files changed, 51 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/renderers/html/SearchbarDataInstallerTest.kt b/plugins/base/src/test/kotlin/renderers/html/SearchbarDataInstallerTest.kt new file mode 100644 index 00000000..33f86e9f --- /dev/null +++ b/plugins/base/src/test/kotlin/renderers/html/SearchbarDataInstallerTest.kt @@ -0,0 +1,46 @@ +package renderers.html + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.junit.Test +import org.junit.jupiter.api.Assertions +import utils.TestOutputWriterPlugin +import utils.pagesJson + +class SearchbarDataInstallerTest: BaseAbstractTest() { + + @Test // see #2289 + fun `should display description of root declarations without a leading dot`() { + val configuration = dokkaConfiguration { + moduleName = "Dokka Module" + + sourceSets { + sourceSet { + sourceRoots = listOf("src/kotlin/Test.kt") + } + } + } + + val source = """ + |/src/kotlin/Test.kt + | + |class Test + | + """.trimIndent() + + val writerPlugin = TestOutputWriterPlugin() + testInline( + source, + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + val searchRecords = writerPlugin.writer.pagesJson() + + Assertions.assertEquals( + "Test", + searchRecords.find { record -> record.name == "class Test" }?.description ?: "" + ) + } + } + } +}
\ No newline at end of file diff --git a/plugins/base/src/test/kotlin/utils/HtmlUtils.kt b/plugins/base/src/test/kotlin/utils/HtmlUtils.kt index bfba882a..0748d91a 100644 --- a/plugins/base/src/test/kotlin/utils/HtmlUtils.kt +++ b/plugins/base/src/test/kotlin/utils/HtmlUtils.kt @@ -1,11 +1,16 @@ package utils +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue +import org.jetbrains.dokka.base.renderers.html.SearchRecord import org.jsoup.Jsoup import org.jsoup.nodes.Element import org.jsoup.select.Elements internal fun TestOutputWriter.navigationHtml(): Element = contents.getValue("navigation.html").let { Jsoup.parse(it) } +internal fun TestOutputWriter.pagesJson(): List<SearchRecord> = jacksonObjectMapper().readValue(contents.getValue("scripts/pages.json")) + internal fun Elements.selectNavigationGrid(): Element { return this.select("div.overview").select("span.nav-link-grid").single() } |