aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt1
-rw-r--r--plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt6
-rw-r--r--plugins/javadoc/src/test/kotlin/javadoc/JavadocPackageTemplateMapTest.kt123
3 files changed, 126 insertions, 4 deletions
diff --git a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt
index 30082092..6cae821d 100644
--- a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt
+++ b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt
@@ -109,4 +109,3 @@ internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() {
}
}
}
-
diff --git a/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt
index 4f9194d7..b8bf41f2 100644
--- a/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt
+++ b/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt
@@ -21,7 +21,7 @@ internal class JavadocModuleTemplateMapTest : AbstractJavadocTemplateMapTest() {
java =
"""
/src/com/test/package/Source.java
- package com.test.package
+ package com.test.package;
public class Test { }
"""
) {
@@ -58,11 +58,11 @@ internal class JavadocModuleTemplateMapTest : AbstractJavadocTemplateMapTest() {
java =
"""
/src/com/test/package0/Test0.java
- package com.test.package0
+ package com.test.package0;
public class Test0 {}
/src/com/test/package1/Test1.java
- package com.test.package1
+ package com.test.package1;
public class Test1 {}
"""
) {
diff --git a/plugins/javadoc/src/test/kotlin/javadoc/JavadocPackageTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/JavadocPackageTemplateMapTest.kt
new file mode 100644
index 00000000..bb53a571
--- /dev/null
+++ b/plugins/javadoc/src/test/kotlin/javadoc/JavadocPackageTemplateMapTest.kt
@@ -0,0 +1,123 @@
+package javadoc
+
+import javadoc.pages.JavadocContentKind
+import javadoc.pages.JavadocPackagePageNode
+import javadoc.pages.RowJavadocListEntry
+import org.jetbrains.dokka.links.DRI
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Disabled
+import org.junit.jupiter.api.Test
+import testApi.utils.assertIsInstance
+
+internal class JavadocPackageTemplateMapTest : AbstractJavadocTemplateMapTest() {
+
+ @Test
+ fun `single class`() {
+ dualTestTemplateMapInline(
+ kotlin =
+ """
+ /src/source.kt
+ package com.test.package0
+ class Test
+ """,
+ java =
+ """
+ /src/com/test/package0/Test.java
+ package com.test.package0;
+ public class Test {}
+ """
+ ) {
+ val map = singlePageOfType<JavadocPackagePageNode>().templateMap
+ assertEquals("Packages", map["tabTitle"])
+ assertEquals("Package", map["colTitle"])
+ assertEquals("com.test.package0", map["title"])
+ assertEquals("", map["subtitle"])
+ assertEquals("package", map["kind"])
+
+ val list = assertIsInstance<List<*>>(map["list"])
+ val entry = assertIsInstance<RowJavadocListEntry>(list.single())
+ assertEquals("Test", entry.link.name)
+ assertEquals(JavadocContentKind.Class, entry.link.kind)
+ assertEquals(DRI("com.test.package0", "Test"), entry.link.dri.single())
+ }
+ }
+
+ @Test
+ fun `multiple packages`() {
+ dualTestTemplateMapInline(
+ kotlin =
+ """
+ /src/source0.kt
+ package com.test.package0
+ class Test0
+
+ /src/source1.kt
+ package com.test.package1
+ class Test1
+ """,
+ java =
+ """
+ /src/com/test/package0/Test0.java
+ package com.test.package0;
+ public class Test0 {}
+
+ /src/com/test/package1/Test1.java
+ package com.test.package1;
+ public class Test1 {}
+ """
+ ) {
+ val packagePages = allPagesOfType<JavadocPackagePageNode>()
+ packagePages.forEach { page ->
+ val map = page.templateMap
+ assertEquals("Packages", map["tabTitle"])
+ assertEquals("Package", map["colTitle"])
+ assertEquals("", map["subtitle"])
+ assertEquals("package", map["kind"])
+ }
+
+ assertEquals(2, packagePages.size, "Expected two package pages")
+ }
+ }
+
+ @Disabled("To be implemented / To be fixed")
+ @Test
+ fun `single class with package documentation`() {
+ dualTestTemplateMapInline(
+ kotlin =
+ """
+ /src/packages.md
+ # Package com.test.package0
+ ABC
+
+ /src/source0.kt
+ package com.test.package0
+ class Test
+ """,
+
+ java =
+ """
+ /src/com/test/package0/package-info.java
+ /**
+ * ABC
+ */
+ package com.test.package0;
+
+ /src/com/test/package0/Test.java
+ package com.test.package0;
+ public class Test{}
+ """,
+ configuration = config.copy(
+ sourceSets = config.sourceSets.map { sourceSet ->
+ sourceSet.copy(
+ includes = listOf("packages.md")
+ )
+ }
+ )
+ ) {
+ val packagePage = singlePageOfType<JavadocPackagePageNode>()
+
+ val map = packagePage.templateMap
+ assertEquals("ABD", map["subtitle"].toString().trim())
+ }
+ }
+}