aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/renderers/html
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin/renderers/html')
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt2
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/TabbedContentTest.kt111
3 files changed, 112 insertions, 3 deletions
diff --git a/plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt b/plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt
index 0e1f53ec..522f9037 100644
--- a/plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt
@@ -38,7 +38,7 @@ class CoverPageTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
val content = writerPlugin.writer.renderedContent("root/example/-result/index.html")
- val tableInheritors = content.select("div.table[data-togglable=Inheritors]").single()
+ val tableInheritors = content.select("div.table").single { it.previousElementSibling()?.text() == "Inheritors" && it.childrenSize() == 2 }
assertEquals(tableInheritors.getElementsContainingOwnText("Failed").singleOrNull()?.tagName(), "a")
assertEquals(tableInheritors.getElementsContainingOwnText("Success").singleOrNull()?.tagName(), "a")
}
diff --git a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
index 94fcd5bf..56329940 100644
--- a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
@@ -3,7 +3,6 @@ package renderers.html
import org.jetbrains.dokka.DokkaConfigurationImpl
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.base.DokkaBase
-import org.jetbrains.dokka.base.renderers.DefaultTabSortingStrategy
import org.jetbrains.dokka.base.renderers.RootCreator
import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProviderFactory
import org.jetbrains.dokka.base.resolvers.external.javadoc.JavadocExternalLocationProviderFactory
@@ -53,7 +52,6 @@ abstract class HtmlRenderingOnlyTestBase : RenderingOnlyTestBase<Element>() {
DokkaBase().htmlPreprocessors to { RootCreator },
DokkaBase().externalLocationProviderFactory to ::JavadocExternalLocationProviderFactory,
DokkaBase().externalLocationProviderFactory to ::DefaultExternalLocationProviderFactory,
- DokkaBase().tabSortingStrategy to { DefaultTabSortingStrategy() },
testConfiguration = configuration
)
diff --git a/plugins/base/src/test/kotlin/renderers/html/TabbedContentTest.kt b/plugins/base/src/test/kotlin/renderers/html/TabbedContentTest.kt
new file mode 100644
index 00000000..306925b3
--- /dev/null
+++ b/plugins/base/src/test/kotlin/renderers/html/TabbedContentTest.kt
@@ -0,0 +1,111 @@
+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.TestOutputWriterPlugin
+import kotlin.test.assertEquals
+
+class TabbedContentTest : BaseAbstractTest() {
+
+ private val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ classpath = listOf(commonStdlibPath!!)
+ externalDocumentationLinks = listOf(stdlibExternalDocumentationLink)
+ }
+ }
+ }
+
+ private fun Element.getTabbedRow(type: String) = select(".table-row[data-togglable=$type]")
+ private fun Element.getTabbedTable(type: String) = select("div[data-togglable=$type] .table")
+
+ @Test
+ fun `should have correct tabbed content type`() {
+ val source = """
+ |/src/main/kotlin/test/Test.kt
+ |package example
+ |
+ |val p = 0
+ |fun foo() = 0
+ |
+ | class A(val d: Int = 0) {
+ | class Success(): Result()
+ | class Failed(): Result()
+ |
+ | fun fn() = 0
+ | }
+ |
+ | fun A.fn() = 0
+ | fun A.fn2() = 0
+ | fun A.fn3() = 0
+ | val A.p = 0
+ | val A.p2 = 0
+ """
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ source,
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val classContent = writerPlugin.writer.renderedContent("root/example/-a/index.html")
+ assertEquals(1, classContent.getTabbedTable("CONSTRUCTOR").size)
+ assertEquals(1, classContent.getTabbedTable("PROPERTY").size)
+ assertEquals(1, classContent.getTabbedTable("CONSTRUCTOR").size)
+ assertEquals(1, classContent.getTabbedTable("FUNCTION").size)
+ assertEquals(1, classContent.getTabbedTable("TYPE").size)
+ assertEquals(3, classContent.getTabbedRow("EXTENSION_FUNCTION").size)
+ assertEquals(2, classContent.getTabbedRow("EXTENSION_PROPERTY").size)
+
+ val packagePage = writerPlugin.writer.renderedContent("root/example/index.html")
+ assertEquals(1, packagePage.getTabbedTable("TYPE").size)
+ assertEquals(1, packagePage.getTabbedTable("PROPERTY").size)
+ assertEquals(1, packagePage.getTabbedTable("FUNCTION").size)
+ assertEquals(3, packagePage.getTabbedRow("EXTENSION_FUNCTION").size)
+ assertEquals(2, packagePage.getTabbedRow("EXTENSION_PROPERTY").size)
+ }
+ }
+ }
+
+
+ @Test
+ fun `should have correct order of members and extensions`() {
+ val source = """
+ |/src/main/kotlin/test/Test.kt
+ |package example
+ |
+ |val p = 0
+ |fun foo() = 0
+ |
+ |class A(val d: Int = 0) {
+ | fun fn() = 0
+ | fun a() = 0
+ | fun g() = 0
+ |}
+ |
+ | fun A.fn() = 0
+ """
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ source,
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val classContent = writerPlugin.writer.renderedContent("root/example/-a/index.html")
+ val funTable = classContent.select("div[data-togglable=FUNCTION] .table")
+ val orders =
+ funTable.select(".table-row").map { it.attr("data-togglable") }
+ assertEquals(listOf("", "", "EXTENSION_FUNCTION", ""), orders)
+ val names =
+ funTable.select(".main-subrow .inline-flex a").map { it.text() }
+ assertEquals(listOf("a", "fn", "fn", "g"), names)
+ }
+ }
+ }
+} \ No newline at end of file