Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* 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>
- Loading branch information
1 parent
9559158
commit c075c95
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
plugins/base/src/test/kotlin/renderers/html/SearchbarDataInstallerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ?: "" | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |