aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-06-30 10:33:20 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-01 09:43:03 +0200
commitfbb5e3a6b79aa771697106b5bb2373d9eaa68290 (patch)
treea2ab8a86935cb8d96a0762b4abaa34d4e54e309e /plugins/javadoc
parentfac44e07465a57bd95a08379caf6ec1f767e8ec7 (diff)
downloaddokka-fbb5e3a6b79aa771697106b5bb2373d9eaa68290.tar.gz
dokka-fbb5e3a6b79aa771697106b5bb2373d9eaa68290.tar.bz2
dokka-fbb5e3a6b79aa771697106b5bb2373d9eaa68290.zip
Implement first simple JavadocPackageTemplateMapTest.kt
Diffstat (limited to 'plugins/javadoc')
-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())
+ }
+ }
+}