diff options
author | Szymon Świstun <sswistun@virtuslab.com> | 2020-01-28 15:36:41 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-10 12:16:32 +0100 |
commit | ee84d85e718bba3a601489a88728ec5ea837849b (patch) | |
tree | 9e2b5d361e72693bccae3dcd818df466f550ca7a /core/src | |
parent | 663d8e04dc78ce9bfe02cb1e84f27faab1e34208 (diff) | |
download | dokka-ee84d85e718bba3a601489a88728ec5ea837849b.tar.gz dokka-ee84d85e718bba3a601489a88728ec5ea837849b.tar.bz2 dokka-ee84d85e718bba3a601489a88728ec5ea837849b.zip |
tests
Diffstat (limited to 'core/src')
-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 |