aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/TestAPI.kt17
-rw-r--r--test/src/format/MarkdownFormatTest.kt16
2 files changed, 33 insertions, 0 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt
index 5a4b9863..a16a0b57 100644
--- a/test/src/TestAPI.kt
+++ b/test/src/TestAPI.kt
@@ -5,6 +5,8 @@ import com.intellij.openapi.util.*
import kotlin.test.fail
import org.jetbrains.dokka.*
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
+import java.io.File
+import kotlin.test.assertEquals
public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> Unit) {
val messageCollector = object : MessageCollector {
@@ -49,6 +51,15 @@ public fun verifyModel(vararg files: String, verifier: (DocumentationModule) ->
Disposer.dispose(environment)
}
+public fun verifyOutput(path: String, outputGenerator: (DocumentationModule, StringBuilder) -> Unit) {
+ verifyModel(path) {
+ val output = StringBuilder()
+ outputGenerator(it, output)
+ val expectedOutput = File(path.replace(".kt", ".md")).readText()
+ assertEquals(expectedOutput, output.toString())
+ }
+}
+
fun StringBuilder.appendChildren(node: ContentNode): StringBuilder {
for (child in node.children) {
val childText = child.toTestString()
@@ -83,3 +94,9 @@ fun ContentNode.toTestString(): String {
appendNode(node)
}.toString()
}
+
+val tempLocation = Location(File("/tmp/out"))
+
+object InMemoryLocationService: LocationService {
+ override fun location(node: DocumentationNode) = tempLocation;
+}
diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt
new file mode 100644
index 00000000..beb727da
--- /dev/null
+++ b/test/src/format/MarkdownFormatTest.kt
@@ -0,0 +1,16 @@
+package org.jetbrains.dokka.tests
+
+import org.junit.Test
+import org.jetbrains.dokka.*
+import java.io.File
+import kotlin.test.assertEquals
+
+public class MarkdownFormatTest {
+ private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService())
+
+ Test fun emptyDescription() {
+ verifyOutput("test/data/format/emptyDescription.kt") { model, output ->
+ markdownService.appendNodes(tempLocation, output, model.members.single().members)
+ }
+ }
+}