aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/test/kotlin
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-06-30 11:29:23 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-01 09:43:03 +0200
commit5090bfb7aec163b39202ef921555ed907b741b29 (patch)
tree02c1a19751d43a5c8c65bdb26a5c0eebb2534c45 /plugins/javadoc/src/test/kotlin
parentfbb5e3a6b79aa771697106b5bb2373d9eaa68290 (diff)
downloaddokka-5090bfb7aec163b39202ef921555ed907b741b29.tar.gz
dokka-5090bfb7aec163b39202ef921555ed907b741b29.tar.bz2
dokka-5090bfb7aec163b39202ef921555ed907b741b29.zip
Implement first JavadocClasslikeTemplateMapTest.kt
Diffstat (limited to 'plugins/javadoc/src/test/kotlin')
-rw-r--r--plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt102
1 files changed, 102 insertions, 0 deletions
diff --git a/plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt
new file mode 100644
index 00000000..4c6e17f0
--- /dev/null
+++ b/plugins/javadoc/src/test/kotlin/javadoc/JavadocClasslikeTemplateMapTest.kt
@@ -0,0 +1,102 @@
+package javadoc
+
+import javadoc.pages.JavadocClasslikePageNode
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Disabled
+import org.junit.jupiter.api.Test
+import testApi.utils.assertIsInstance
+
+@Disabled("To be fixed")
+internal class JavadocClasslikeTemplateMapTest : AbstractJavadocTemplateMapTest() {
+
+ @Test
+ fun `empty class`() {
+ dualTestTemplateMapInline(
+ kotlin =
+ """
+ /src/source0.kt
+ package com.test.package
+ /**
+ * Documentation for TestClass
+ */
+ class TestClass
+ """,
+ java =
+ """
+ /src/com/test/package/TestClass.java
+ package com.test.package;
+ /**
+ * Documentation for TestClass
+ */
+ public class TestClass {}
+ """
+ ) {
+ val map = singlePageOfType<JavadocClasslikePageNode>().templateMap
+ assertEquals("TestClass", map["name"])
+ assertEquals("TestClass", map["title"])
+ assertEquals("com.test.package", map["packageName"])
+ assertEquals("Documentation for TestClass", map["classlikeDocumentation"])
+ assertEquals("Documentation for TestClass", map["subtitle"])
+ assertEquals("public final class <a href=TestClass.html>TestClass</a>", map["signature"])
+ }
+ }
+
+ @Test
+ fun `single function`() {
+ dualTestTemplateMapInline(
+ kotlin =
+ """
+ /src/source0.kt
+ package com.test.package0
+ /**
+ * Documentation for TestClass
+ */
+ class TestClass {
+ /**
+ * Documentation for testFunction
+ */
+ fun testFunction(): String = ""
+ }
+ """,
+ java =
+ """
+ /src/com/test/package0/TestClass.java
+ package com.test.package0
+ /**
+ * Documentation for TestClass
+ */
+ public class TestClass {
+ /**
+ * Documentation for testFunction
+ */
+ public String testFunction() {
+ return "";
+ }
+ }
+ """
+ ) {
+ val map = singlePageOfType<JavadocClasslikePageNode>().templateMap
+
+ assertEquals("TestClass", map["name"])
+ assertEquals("TestClass", map["title"])
+ assertEquals("com.test.package0", map["packageName"])
+ assertEquals("Documentation for TestClass", map["classlikeDocumentation"])
+ assertEquals("Documentation for TestClass", map["subtitle"])
+ assertEquals("public final class <a href=TestClass.html>TestClass</a>", map["signature"])
+
+ val methods = assertIsInstance<Map<Any, Any?>>(map["methods"])
+ val ownMethods = assertIsInstance<List<*>>(methods["own"])
+ assertEquals(1, ownMethods.size, "Expected only one method")
+ val method = assertIsInstance<Map<Any, Any?>>(ownMethods.single())
+ assertEquals("Documentation for testFunction", method["brief"])
+ assertEquals("testFunction", method["name"])
+ assertEquals(
+ 0, assertIsInstance<List<*>>(method["parameters"]).size,
+ "Expected no parameters"
+ )
+ assertEquals(
+ "final <a href=.html>String</a> <a href=.html>testFunction</a>()", method["signature"]
+ )
+ }
+ }
+}