aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/markdown
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-03-01 12:01:41 +0100
committerGitHub <noreply@github.com>2021-03-01 12:01:41 +0100
commitab853a866c40771e84a3235f40575efe04c435c5 (patch)
tree81f4df0d5ead3bac649f9ac61a04864ebcb57c44 /plugins/base/src/test/kotlin/markdown
parentce962389afe86c0d54a08df942e564a077b25c3f (diff)
downloaddokka-ab853a866c40771e84a3235f40575efe04c435c5.tar.gz
dokka-ab853a866c40771e84a3235f40575efe04c435c5.tar.bz2
dokka-ab853a866c40771e84a3235f40575efe04c435c5.zip
Add explicit exceptions in markdown and allow for empty link destinations (#1757)
Diffstat (limited to 'plugins/base/src/test/kotlin/markdown')
-rw-r--r--plugins/base/src/test/kotlin/markdown/ParserTest.kt44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt
index 0fdb10c1..4ac4a43f 100644
--- a/plugins/base/src/test/kotlin/markdown/ParserTest.kt
+++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt
@@ -5,6 +5,9 @@ import org.intellij.markdown.MarkdownElementTypes
import org.jetbrains.dokka.model.doc.*
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
class ParserTest : KDocTest() {
@@ -1437,5 +1440,46 @@ class ParserTest : KDocTest() {
)
executeTest(kdoc, expectedDocumentationNode)
}
+
+ @Test
+ fun `short link without destination`() {
+ val kdoc = """
+ | This is [link]()
+ """.trimMargin()
+ val expectedDocumentationNode = DocumentationNode(
+ listOf(
+ Description(
+ CustomDocTag(
+ listOf(
+ P(
+ listOf(
+ Text("This is "),
+ A(
+ listOf(Text("link")),
+ mapOf("href" to "")
+ )
+ )
+ )
+ ), name = MarkdownElementTypes.MARKDOWN_FILE.name
+ )
+ )
+ )
+ )
+ executeTest(kdoc, expectedDocumentationNode)
+ }
+
+ @Test
+ fun `exception thrown by empty header should point to location of a file`() {
+ val kdoc = """
+ | ###
+ """.trimMargin()
+ val expectedDocumentationNode = DocumentationNode(emptyList())
+ val exception = runCatching { executeTest(kdoc, expectedDocumentationNode) }.exceptionOrNull()
+
+ assertEquals(
+ "Wrong AST Tree. Header does not contain expected content in Test.kt/example.Test, element starts from offset 0 and ends 3: ###",
+ exception?.message
+ )
+ }
}