1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package packageList
import org.jetbrains.dokka.base.renderers.PackageListService
import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
import kotlin.test.Test
import kotlin.test.assertEquals
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)
}
}
|