diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-04-29 15:03:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 15:03:08 +0300 |
commit | 8c218ff4dd5f970233c43845c19299fc74256389 (patch) | |
tree | b6818183ce8faa2c58d6571ca1c86aa28d4f0431 /plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt | |
parent | 84aacad29982240ae367b21e9d283d38dab672ae (diff) | |
download | dokka-8c218ff4dd5f970233c43845c19299fc74256389.tar.gz dokka-8c218ff4dd5f970233c43845c19299fc74256389.tar.bz2 dokka-8c218ff4dd5f970233c43845c19299fc74256389.zip |
Enable warnings as errors and fix all warnings (#2451)
* Enable warnings as errors and fix all warnings
* Enable skip-metadata-version-check compiler setting
Diffstat (limited to 'plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt')
-rw-r--r-- | plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt b/plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt deleted file mode 100644 index 81d39752..00000000 --- a/plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt +++ /dev/null @@ -1,137 +0,0 @@ -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.templating.AddToNavigationCommand -import org.jetbrains.dokka.plugability.DokkaContext -import org.junit.Rule -import org.junit.jupiter.api.Test -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.ValueSource -import org.junit.rules.TemporaryFolder -import utils.assertHtmlEqualsIgnoringWhitespace - -class AddToNavigationCommandResolutionTest : TemplatingAbstractTest() { - @get:Rule - val folder: TemporaryFolder = TemporaryFolder() - - @Test - fun `should substitute AddToNavigationCommand in root directory`() = - addToNavigationTest { - val output = folder.root.resolve("navigation.html").readText() - val expected = expectedOutput( - ModuleWithPrefix("module1"), - ModuleWithPrefix("module2") - ) - assertHtmlEqualsIgnoringWhitespace(expected, output) - } - - @ParameterizedTest - @ValueSource(strings = ["module1", "module2"]) - fun `should substitute AddToNavigationCommand in modules directory`(moduleName: String) = - addToNavigationTest { - val output = folder.root.resolve(moduleName).resolve("navigation.html").readText() - val expected = expectedOutput( - ModuleWithPrefix("module1", ".."), - ModuleWithPrefix("module2", "..") - ) - assertHtmlEqualsIgnoringWhitespace(expected, output) - } - - private fun expectedOutput(vararg modulesWithPrefix: ModuleWithPrefix) = createHTML(prettyPrint = true) - .div("sideMenu") { - modulesWithPrefix.forEach { (moduleName, prefix) -> - val relativePrefix = prefix?.let { "$it/" } ?: "" - div("sideMenuPart") { - id = "$moduleName-nav-submenu" - div("overview") { - a { - href = "$relativePrefix$moduleName/module-page.html" - span { - +"module-$moduleName" - } - } - } - div("sideMenuPart") { - id = "$moduleName-nav-submenu-0" - div("overview") { - a { - href = "$relativePrefix$moduleName/$moduleName/package-page.html" - span { - +"package-$moduleName" - } - } - } - } - } - } - } - - private fun inputForModule(moduleName: String) = createHTML() - .templateCommand(AddToNavigationCommand(moduleName)) { - div("sideMenuPart") { - id = "$moduleName-nav-submenu" - div("overview") { - a { - href = "module-page.html" - span { - +"module-$moduleName" - } - } - } - div("sideMenuPart") { - id = "$moduleName-nav-submenu-0" - div("overview") { - a { - href = "$moduleName/package-page.html" - span { - +"package-$moduleName" - } - } - } - } - } - } - - private fun addToNavigationTest(test: (DokkaContext) -> Unit) { - folder.create() - val module1 = folder.newFolder("module1") - val module2 = folder.newFolder("module2") - - val configuration = dokkaConfiguration { - modules = listOf( - DokkaModuleDescriptionImpl( - name = "module1", - relativePathToOutputDirectory = module1, - includes = emptySet(), - sourceOutputDirectory = module1, - ), - DokkaModuleDescriptionImpl( - name = "module2", - relativePathToOutputDirectory = module2, - includes = emptySet(), - sourceOutputDirectory = module2, - ), - ) - this.outputDir = folder.root - } - - val module1Navigation = module1.resolve("navigation.html") - module1Navigation.writeText(inputForModule("module1")) - val module2Navigation = module2.resolve("navigation.html") - module2Navigation.writeText(inputForModule("module2")) - - testFromData(configuration, useOutputLocationFromConfig = true) { - finishProcessingSubmodules = { ctx -> - test(ctx) - } - } - } - - private data class ModuleWithPrefix(val moduleName: String, val prefix: String? = null) -} |