aboutsummaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/kotlin/dri/DRITest.kt37
-rw-r--r--core/src/test/kotlin/externalLocationProviders/ExternalLocationProviderTest.kt25
-rw-r--r--core/src/test/kotlin/linkResolvers/LinkResolverTest.kt92
3 files changed, 154 insertions, 0 deletions
diff --git a/core/src/test/kotlin/dri/DRITest.kt b/core/src/test/kotlin/dri/DRITest.kt
new file mode 100644
index 00000000..b763bce8
--- /dev/null
+++ b/core/src/test/kotlin/dri/DRITest.kt
@@ -0,0 +1,37 @@
+package org.jetbrains.dokka.tests.dri
+
+import org.jetbrains.dokka.links.Callable
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.resolvers.toJavadocLocation
+import org.junit.Test
+import kotlin.test.assertEquals
+
+class DRITest {
+ @Test
+ fun onlyClassNames() {
+ val expected = DRI(classNames = "className1.className2")
+ val actual = DRI.from("/className1.className2////")
+ assertEquals(expected, actual)
+ }
+
+ @Test
+ fun fullDRI() {
+ val expected = DRI("org.dokka", "className1.className2", Callable("<init>", "", "", listOf("Int")), 2, "something" )
+ val actual = DRI.from("org.dokka/className1.className2/<init>/..Int/2/something")
+ assertEquals(expected, actual)
+ }
+
+ @Test
+ fun onlyExtra() {
+ val expected = DRI(null, null, null, null, "extra" )
+ val actual = DRI.from("/////extra")
+ assertEquals(expected, actual)
+ }
+
+ @Test
+ fun javadoc8Location() {
+ val dri = DRI("org.jetbrains.dokka", "DRITest", "javadocLocation", ".void.")
+ assertEquals("org/jetbrains/dokka/DRITest.html#javadocLocation--", dri.toJavadocLocation(8))
+ }
+}
+
diff --git a/core/src/test/kotlin/externalLocationProviders/ExternalLocationProviderTest.kt b/core/src/test/kotlin/externalLocationProviders/ExternalLocationProviderTest.kt
new file mode 100644
index 00000000..860f4534
--- /dev/null
+++ b/core/src/test/kotlin/externalLocationProviders/ExternalLocationProviderTest.kt
@@ -0,0 +1,25 @@
+package org.jetbrains.dokka.tests.externalLocationProviders
+
+import junit.framework.Assert.assertEquals
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.resolvers.ExternalLocationProvider
+import org.junit.Test
+
+
+class ExternalLocationProviderTest {
+ val stdlibLink = DokkaConfiguration.ExternalDocumentationLink.Builder("https://kotlinlang.org/api/latest/jvm/stdlib/").build()
+ @Test fun kotlinString() {
+ val dri = DRI("kotlin", "String")
+ val link = ExternalLocationProvider.getLocation(dri, listOf(stdlibLink.packageListUrl))
+ assertEquals("kotlin/-string/index.html", link)
+ }
+
+ @Test fun kotlinCompareTo() {
+ val dri = DRI("kotlin", "String", "compareTo", "#Int#String")
+ val link = ExternalLocationProvider.getLocation(dri, listOf(stdlibLink.packageListUrl))
+ assertEquals("kotlin/-string/compare-to.html", link)
+ }
+
+}
+
diff --git a/core/src/test/kotlin/linkResolvers/LinkResolverTest.kt b/core/src/test/kotlin/linkResolvers/LinkResolverTest.kt
new file mode 100644
index 00000000..b2cccce2
--- /dev/null
+++ b/core/src/test/kotlin/linkResolvers/LinkResolverTest.kt
@@ -0,0 +1,92 @@
+package org.jetbrains.dokka.tests.linkResolvers
+//
+//import junit.framework.Assert.assertEquals
+//import org.jetbrains.dokka.testApi.DokkaConfigurationImpl
+//import org.jetbrains.dokka.Platform
+//import org.jetbrains.dokka.links.DRI
+//import org.jetbrains.dokka.pages.*
+//import org.jetbrains.dokka.renderers.FileWriter
+//import org.jetbrains.dokka.renderers.NewHtmlRenderer
+//import org.jetbrains.dokka.resolvers.DefaultLocationProvider
+//import org.junit.Test
+//
+//
+//class LinkResolverTest {
+//
+// fun createModel(): ModulePageNode {
+// val platform = listOf(PlatformData("jvm", Platform.jvm))
+//
+// val moduleSymbol = ContentSymbol(
+// listOf(ContentText("moduleName", platform)),
+// platform)
+//
+// val packageDRI = DRI("packageName")
+//
+// val module = ModulePageNode("",
+// listOf(moduleSymbol, ContentBlock(
+// "packages",
+// listOf(ContentGroup(listOf(ContentLink("packageName", packageDRI, platform)), platform)),
+// platform)
+// ),
+// null)
+//
+// val packageSymbol = ContentSymbol(
+// listOf(ContentText("package moduleName.packageName", platform)),
+// platform)
+//
+// val packageNode = PackagePageNode("packageName", listOf(packageSymbol), module, DRI("packageName"))
+//
+// val classSymbol = ContentSymbol(
+// listOf(ContentText("class ClassName()", platform)),
+// platform)
+//
+// val classNode = ClassPageNode("className", listOf(classSymbol), packageNode, DRI("packageName", "className"))
+//
+// val memberSymbol = ContentSymbol(
+// listOf(ContentText("fun funName(): String", platform)),
+// platform)
+//
+// val memberText = ContentText("This is some docs for funName", platform)
+//
+// val memberNode = MemberPageNode("funName",
+// listOf(memberSymbol, ContentComment(listOf(memberText), platform)),
+// classNode,
+// DRI("packageName", "className", "funName", "..."))
+//
+// module.appendChild(packageNode)
+// packageNode.appendChild(classNode)
+// classNode.appendChild(memberNode)
+// return module
+// }
+//
+// @Test fun memberLink() {
+// val model = createModel()
+// val linkResolver = DefaultLocationProvider(model, DokkaConfigurationImpl())
+// val link = linkResolver.resolve(model.children.first().children.first().children.first())
+// assertEquals("/--root--/package-name/class-name/fun-name", link)
+// }
+//
+// @Test fun classLink() {
+// val model = createModel()
+// val linkResolver = DefaultLocationProvider(model, DokkaConfigurationImpl())
+// val link = linkResolver.resolve(model.children.first().children.first())
+// assertEquals("/--root--/package-name/class-name/index", link)
+// }
+//
+// @Test fun moduleLink() {
+// val model = createModel()
+// val linkResolver = DefaultLocationProvider(model, DokkaConfigurationImpl())
+// val link = linkResolver.resolve(model)
+// assertEquals("/--root--/index", link)
+// }
+//
+// @Test fun writeToFile() {
+// val model = createModel()
+// val linkResolver = DefaultLocationProvider(model, DokkaConfigurationImpl())
+// val fileWriter = FileWriter("/Users/kamildoleglo/IdeaProjects/dokka/build/dokka", ".html")
+// val renderer = NewHtmlRenderer("/Users/kamildoleglo/IdeaProjects/dokka/build/dokka", fileWriter, linkResolver)
+// renderer.render(model)
+// }
+//
+//}
+//