aboutsummaryrefslogtreecommitdiff
path: root/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt')
-rw-r--r--plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt62
1 files changed, 52 insertions, 10 deletions
diff --git a/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt b/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt
index ce2a8afd..44acf340 100644
--- a/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt
+++ b/plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt
@@ -3,13 +3,15 @@ package org.jetbrains.dokka.templates
import kotlinx.html.a
import kotlinx.html.div
import kotlinx.html.id
+import kotlinx.html.span
import kotlinx.html.stream.createHTML
import org.jetbrains.dokka.DokkaModuleDescriptionImpl
import org.jetbrains.dokka.base.renderers.html.templateCommand
+import org.jetbrains.dokka.base.renderers.html.templateCommandAsHtmlComment
import org.jetbrains.dokka.base.templating.PathToRootSubstitutionCommand
import org.junit.Rule
-import org.junit.rules.TemporaryFolder
import org.junit.jupiter.api.Test
+import org.junit.rules.TemporaryFolder
import utils.assertHtmlEqualsIgnoringWhitespace
import java.io.File
@@ -36,7 +38,56 @@ class SubstitutionCommandResolutionTest : TemplatingAbstractTest() {
id = "logo"
}
}
+ checkSubstitutedResult(template, expected)
+ }
+
+ @Test
+ fun `should handle PathToRootCommand as HTML comment`() {
+ val template = createHTML().span {
+ templateCommandAsHtmlComment(PathToRootSubstitutionCommand(pattern = "###", default = "default")) {
+ this@span.a {
+ href = "###index.html"
+ div {
+ id = "logo"
+ }
+ }
+ templateCommandAsHtmlComment(PathToRootSubstitutionCommand(pattern = "####", default = "default")) {
+ this@span.a {
+ href = "####index.html"
+ div {
+ id = "logo"
+ }
+ }
+ }
+ }
+ }
+
+ val expected = createHTML().span {
+ a {
+ href = "../index.html"
+ div {
+ id = "logo"
+ }
+ }
+ a {
+ href = "../index.html"
+ div {
+ id = "logo"
+ }
+ }
+ }
+ checkSubstitutedResult(template, expected)
+ }
+
+ private fun createDirectoriesAndWriteContent(content: String): File {
+ folder.create()
+ val module1 = folder.newFolder("module1")
+ val module1Content = module1.resolve("index.html")
+ module1Content.writeText(content)
+ return module1Content
+ }
+ private fun checkSubstitutedResult(template: String, expected:String) {
val testedFile = createDirectoriesAndWriteContent(template)
val configuration = dokkaConfiguration {
@@ -57,13 +108,4 @@ class SubstitutionCommandResolutionTest : TemplatingAbstractTest() {
}
}
}
-
- private fun createDirectoriesAndWriteContent(content: String): File {
- folder.create()
- val module1 = folder.newFolder("module1")
- val module1Content = module1.resolve("index.html")
- module1Content.writeText(content)
- return module1Content
- }
-
}