diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-02-10 17:05:11 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-12 14:29:06 +0100 |
commit | 2d9f0753bb925f6a6d08ab7e67d5676c196de7d0 (patch) | |
tree | 5d7dea95cd58c4755ed74d6e9b8170f9d028a4b2 /core/src/test/kotlin/markdown | |
parent | 18e28d080792d3f805d8e3c787675712d6b9b7ce (diff) | |
download | dokka-2d9f0753bb925f6a6d08ab7e67d5676c196de7d0.tar.gz dokka-2d9f0753bb925f6a6d08ab7e67d5676c196de7d0.tar.bz2 dokka-2d9f0753bb925f6a6d08ab7e67d5676c196de7d0.zip |
Adds requested changes
Diffstat (limited to 'core/src/test/kotlin/markdown')
-rw-r--r-- | core/src/test/kotlin/markdown/KDocTest.kt | 48 | ||||
-rw-r--r-- | core/src/test/kotlin/markdown/ParserTest.kt | 18 |
2 files changed, 64 insertions, 2 deletions
diff --git a/core/src/test/kotlin/markdown/KDocTest.kt b/core/src/test/kotlin/markdown/KDocTest.kt new file mode 100644 index 00000000..c084154b --- /dev/null +++ b/core/src/test/kotlin/markdown/KDocTest.kt @@ -0,0 +1,48 @@ +package markdown + +import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.doc.DocumentationNode +import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Assert +import testApi.testRunner.AbstractCoreTest + +open class KDocTest : AbstractCoreTest() { + + private val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/example/Test.kt") + } + } + } + + private fun interpolateKdoc(kdoc: String) = """ + |/src/main/kotlin/example/Test.kt + |package example + | /** + ${kdoc.split("\n").joinToString("") { "| * $it\n" } } + | */ + |class Test + """.trimMargin() + + private fun actualDocumentationNode(modulePageNode: ModulePageNode) = + (modulePageNode.documentable?.children?.first() as Package) + .classlikes.first() + .platformInfo.first() + .documentationNode + + + protected fun executeTest(kdoc: String, expectedDocumentationNode: DocumentationNode) { + testInline( + interpolateKdoc(kdoc), + configuration + ) { + pagesGenerationStage = { + Assert.assertEquals( + expectedDocumentationNode, + actualDocumentationNode(it) + ) + } + } + } +}
\ No newline at end of file diff --git a/core/src/test/kotlin/markdown/ParserTest.kt b/core/src/test/kotlin/markdown/ParserTest.kt index 77ccd769..107940f6 100644 --- a/core/src/test/kotlin/markdown/ParserTest.kt +++ b/core/src/test/kotlin/markdown/ParserTest.kt @@ -1,12 +1,12 @@ package org.jetbrains.dokka.tests +import markdown.KDocTest import org.jetbrains.dokka.model.doc.* import org.junit.Ignore import org.junit.Test -import testApi.testRunner.AbstractKDocTest -class ParserTest : AbstractKDocTest() { +class ParserTest : KDocTest() { @Test fun `Simple text`() { val kdoc = """ @@ -897,5 +897,19 @@ class ParserTest : AbstractKDocTest() { ) executeTest(kdoc, expectedDocumentationNode) } + + @Test fun `Windows Carriage Return Line Feed`() { + val kdoc = "text\r\ntext" + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P(listOf( + Text(body = "text\ntext") + )) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } } |