aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/packageList
diff options
context:
space:
mode:
authorKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2021-07-05 14:10:23 +0200
committerGitHub <noreply@github.com>2021-07-05 14:10:23 +0200
commit0bf1d0f5491a62c56393a06cdfb4168778d9829e (patch)
tree808f631e72b652dc2c3d5929f85f677968bc56f6 /plugins/base/src/test/kotlin/packageList
parenta1d44ab80df217196fe5ee9455c7cf1c135e3b07 (diff)
downloaddokka-0bf1d0f5491a62c56393a06cdfb4168778d9829e.tar.gz
dokka-0bf1d0f5491a62c56393a06cdfb4168778d9829e.tar.bz2
dokka-0bf1d0f5491a62c56393a06cdfb4168778d9829e.zip
Flatten multi-module structure (#1980)
* Add support for multimodule package lists * Merge package-lists in multi-module generation * Remove double-wrapping of modules in multi-module generation * Handle empty modules in package lists
Diffstat (limited to 'plugins/base/src/test/kotlin/packageList')
-rw-r--r--plugins/base/src/test/kotlin/packageList/PackageListTest.kt65
1 files changed, 65 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/packageList/PackageListTest.kt b/plugins/base/src/test/kotlin/packageList/PackageListTest.kt
new file mode 100644
index 00000000..310a23c6
--- /dev/null
+++ b/plugins/base/src/test/kotlin/packageList/PackageListTest.kt
@@ -0,0 +1,65 @@
+package packageList
+
+import org.jetbrains.dokka.base.renderers.PackageListService
+import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+
+class PackageListTest {
+ @Test
+ fun `one module package list is created correctly`() {
+ val nonStandardLocations = mapOf("//longArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Long]/PointingToDeclaration/" to "[JS root]/long-array-with-fun.html")
+ val modules = mapOf("" to setOf("foo", "bar", "baz"))
+ val format = RecognizedLinkFormat.DokkaHtml
+ val output = PackageListService.renderPackageList(nonStandardLocations, modules, format.formatName, format.linkExtension)
+ val expected = """
+ |${'$'}dokka.format:html-v1
+ |${'$'}dokka.linkExtension:html
+ |${'$'}dokka.location://longArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Long]/PointingToDeclaration/[JS root]/long-array-with-fun.html
+ |bar
+ |baz
+ |foo
+ |""".trimMargin()
+ assertEquals(expected, output)
+ }
+
+ @Test
+ fun `multi-module package list is created correctly`() {
+ val nonStandardLocations = mapOf("//longArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Long]/PointingToDeclaration/" to "[JS root]/long-array-with-fun.html")
+ val modules = mapOf("moduleA" to setOf("foo", "bar"), "moduleB" to setOf("baz"), "moduleC" to setOf("qux"))
+ val format = RecognizedLinkFormat.DokkaHtml
+ val output = PackageListService.renderPackageList(nonStandardLocations, modules, format.formatName, format.linkExtension)
+ val expected = """
+ |${'$'}dokka.format:html-v1
+ |${'$'}dokka.linkExtension:html
+ |${'$'}dokka.location://longArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Long]/PointingToDeclaration/[JS root]/long-array-with-fun.html
+ |module:moduleA
+ |bar
+ |foo
+ |module:moduleB
+ |baz
+ |module:moduleC
+ |qux
+ |""".trimMargin()
+ assertEquals(expected, output)
+ }
+
+ @Test
+ fun `empty package set in module`() {
+ val nonStandardLocations = emptyMap<String, String>()
+ val modules = mapOf("moduleA" to setOf("foo", "bar"), "moduleB" to emptySet(), "moduleC" to setOf("qux"))
+ val format = RecognizedLinkFormat.DokkaHtml
+ val output = PackageListService.renderPackageList(nonStandardLocations, modules, format.formatName, format.linkExtension)
+ val expected = """
+ |${'$'}dokka.format:html-v1
+ |${'$'}dokka.linkExtension:html
+ |
+ |module:moduleA
+ |bar
+ |foo
+ |module:moduleC
+ |qux
+ |""".trimMargin()
+ assertEquals(expected, output)
+ }
+}