aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-03-23 08:51:16 +0100
committerPaweł Marks <pmarks@virtuslab.com>2020-03-23 08:51:16 +0100
commitec5990f948647c245a5f7996bb8a9f62ccc6a3c5 (patch)
tree8b75b5d0af8ceb5b011e5aaffb9311c8b533b0ef
parentfc30a08beb509a03112298a6dd52c5001a2c6a53 (diff)
downloaddokka-ec5990f948647c245a5f7996bb8a9f62ccc6a3c5.tar.gz
dokka-ec5990f948647c245a5f7996bb8a9f62ccc6a3c5.tar.bz2
dokka-ec5990f948647c245a5f7996bb8a9f62ccc6a3c5.zip
Add extracting Main content group from kotlin-as-java tests
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt29
1 files changed, 14 insertions, 15 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
index 2a9ddf0e..968ab65a 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
@@ -1,9 +1,6 @@
package kotlinAsJavaPlugin
-import org.jetbrains.dokka.pages.ContentGroup
-import org.jetbrains.dokka.pages.ContentPage
-import org.jetbrains.dokka.pages.ContentTable
-import org.jetbrains.dokka.pages.children
+import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.junit.jupiter.api.Test
@@ -38,14 +35,11 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() {
cleanupOutput = true
) {
pagesGenerationStage = { root ->
- val content = (root.children.firstOrNull()?.children?.firstOrNull() as? ContentPage)?.content ?: run {
- fail("Either children or content is null")
- }
+ val content = (root.children.single().children.first { it.name == "TestKt" } as ContentPage).content
- val children =
- if (content is ContentGroup)
- content.children.filterIsInstance<ContentTable>().filter { it.children.isNotEmpty() }
- else emptyList()
+ val children = content.mainContents
+ .filterIsInstance<ContentTable>()
+ .filter { it.children.isNotEmpty() }
children.assertCount(2)
}
@@ -83,9 +77,9 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() {
.map { it.content }
val children = contentList.flatMap { content ->
- if (content is ContentGroup)
- content.children.filterIsInstance<ContentTable>().filter { it.children.isNotEmpty() }
- else emptyList()
+ content.mainContents
+ .filterIsInstance<ContentTable>()
+ .filter { it.children.isNotEmpty() }
}.filterNot { it.toString().contains("<init>") }
children.assertCount(4)
@@ -140,4 +134,9 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() {
private fun <T> Collection<T>.assertCount(n: Int, prefix: String = "") =
assert(count() == n) { "${prefix}Expected $n, got ${count()}" }
-} \ No newline at end of file
+}
+
+private val ContentNode.mainContents: List<ContentNode>
+ get() = (this as ContentGroup).children
+ .filterIsInstance<ContentGroup>()
+ .single { it.dci.kind == ContentKind.Main }.children