diff options
-rw-r--r-- | core/src/test/kotlin/basic/DokkaBasicTests.kt | 6 | ||||
-rw-r--r-- | core/src/test/kotlin/enums/EnumsTest.kt | 45 |
2 files changed, 51 insertions, 0 deletions
diff --git a/core/src/test/kotlin/basic/DokkaBasicTests.kt b/core/src/test/kotlin/basic/DokkaBasicTests.kt index d418e36a..021f110c 100644 --- a/core/src/test/kotlin/basic/DokkaBasicTests.kt +++ b/core/src/test/kotlin/basic/DokkaBasicTests.kt @@ -1,5 +1,7 @@ package basic +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ModulePageNode import org.junit.Test import testApi.testRunner.AbstractCoreTest @@ -29,7 +31,11 @@ class DokkaBasicTests : AbstractCoreTest() { ) { pagesGenerationStage = { println(it.dri) + assert(it.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size == 5) } } } + + fun ModulePageNode.getClasslikeToMemberMap() = + this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy ({it.value}){it.key} }
\ No newline at end of file diff --git a/core/src/test/kotlin/enums/EnumsTest.kt b/core/src/test/kotlin/enums/EnumsTest.kt new file mode 100644 index 00000000..efc46595 --- /dev/null +++ b/core/src/test/kotlin/enums/EnumsTest.kt @@ -0,0 +1,45 @@ +package enums + +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Test +import testApi.testRunner.AbstractCoreTest + +class EnumsTest : AbstractCoreTest() { + + @Test + fun basicEnums() { + val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package enums + | + |enum class Test { + | E1, + | E2 + |} + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { + val map = it.getClasslikeToMemberMap() + val test = map.filterKeys { it.name == "Test" }.values.firstOrNull() + assert(test != null) { "Test not found" } + assert(test!!.any { it.name == "E1" } && test.any { it.name == "E2" }) { "Enum entries missing in parent" } + assert(map.keys.any { it.name == "E1" } && map.keys.any { it.name == "E2" }) { "Enum entries missing" } + } + } + } + + + fun ModulePageNode.getClasslikeToMemberMap() = + this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy({ it.value }) { it.key } +}
\ No newline at end of file |