-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle empty modules in package lists
- Loading branch information
1 parent
53a6327
commit 8e4e226
Showing
4 changed files
with
93 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
plugins/base/src/test/kotlin/packageList/PackageListTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters