aboutsummaryrefslogtreecommitdiff
path: root/plugins/templating/src/test
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2022-02-22 12:56:41 +0300
committerGitHub <noreply@github.com>2022-02-22 12:56:41 +0300
commitb9b1b588fad604c0cfc3e481f48338437dcaba5f (patch)
tree7c6a04d95f0f9b0c931b25dca91f1cf411f01105 /plugins/templating/src/test
parentc44bf5487bd32f90a4576859548f1db0e9355a07 (diff)
downloaddokka-b9b1b588fad604c0cfc3e481f48338437dcaba5f.tar.gz
dokka-b9b1b588fad604c0cfc3e481f48338437dcaba5f.tar.bz2
dokka-b9b1b588fad604c0cfc3e481f48338437dcaba5f.zip
Fix HTML head and favicon in multi-module projects (#2365)
Diffstat (limited to 'plugins/templating/src/test')
-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
- }
-
}