diff options
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r-- | plugins/base/src/test/kotlin/markdown/ParserTest.kt | 53 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/model/CommentTest.kt | 16 |
2 files changed, 67 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt index 3498f73f..8e813eba 100644 --- a/plugins/base/src/test/kotlin/markdown/ParserTest.kt +++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt @@ -2,16 +2,18 @@ package org.jetbrains.dokka.tests import markdown.KDocTest import org.intellij.markdown.MarkdownElementTypes +import org.jetbrains.dokka.base.parsers.MarkdownParser 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() { + private fun parseMarkdownToDocNode(text: String) = + MarkdownParser( { null }, "").parseStringToDocNode(text) + @Test fun `Simple text`() { val kdoc = """ @@ -1519,5 +1521,52 @@ class ParserTest : KDocTest() { ) executeTest(kdoc, expectedDocumentationNode) } + + @Test + fun `code with backticks`() { + val kdoc = "` `` ` ` ``` `" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + CustomDocTag( + listOf( + P( + listOf( + CodeInline(listOf(Text("`` "))), + Text(" "), + CodeInline(listOf(Text("``` "))), + ) + ) + ), name = MarkdownElementTypes.MARKDOWN_FILE.name + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } + + @Test + fun `should filter spaces in markdown`() { + val markdown = """ + | sdsdds f,*()hhh + | dssd hf + | + | sdsdsds sdd + | + | + | eweww + | + | + | + """.trimMargin() + val actualDocumentationNode = parseMarkdownToDocNode(markdown).children + val expectedDocumentationNode = listOf( + P(listOf(Text(" sdsdds f,*()hhh dssd hf"))), + P(listOf(Text(" sdsdsds sdd"))), + P(listOf(Text(" eweww "))) + ) + print(expectedDocumentationNode) + assertEquals(actualDocumentationNode, expectedDocumentationNode) + } } diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt index 6a7b2d89..0742587a 100644 --- a/plugins/base/src/test/kotlin/model/CommentTest.kt +++ b/plugins/base/src/test/kotlin/model/CommentTest.kt @@ -251,4 +251,20 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme } } } + + @Test + fun `should be space between Markdown nodes`() { + inlineModelTest( + """ + |/** + | * Rotates paths by `amount` **radians** around (`x`, `y`). + | */ + |val property = "test" + """ + ) { + with((this / "comment" / "property").cast<DProperty>()) { + comments() equals "Rotates paths by amount radians around (x, y).\n" + } + } + } } |