aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-08-30 15:58:46 +0200
committerGitHub <noreply@github.com>2023-08-30 15:58:46 +0200
commitc63ea36637ce956029fb15b1482c0683ecb8a587 (patch)
tree2b75a8a976b43530820e73dc60cce4b10d9fc005 /plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
parent0e00edc6fcd406fcf38673ef6a2f8f59e8374de2 (diff)
downloaddokka-c63ea36637ce956029fb15b1482c0683ecb8a587.tar.gz
dokka-c63ea36637ce956029fb15b1482c0683ecb8a587.tar.bz2
dokka-c63ea36637ce956029fb15b1482c0683ecb8a587.zip
Migrate to JUnit 5 and unify used test API (#3138)
Diffstat (limited to 'plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt')
-rw-r--r--plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt90
1 files changed, 44 insertions, 46 deletions
diff --git a/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt b/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
index b38fb03f..9bb6ee89 100644
--- a/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
+++ b/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
@@ -8,67 +8,65 @@ import org.jetbrains.dokka.gfm.GfmPlugin
import org.jetbrains.dokka.gfm.ResolveLinkGfmCommand
import org.jetbrains.dokka.gfm.templateProcessing.GfmTemplateProcessingPlugin
import org.jetbrains.dokka.links.DRI
-import org.junit.Rule
-import org.junit.jupiter.api.Test
-import org.junit.rules.TemporaryFolder
+import org.junit.jupiter.api.io.TempDir
import java.io.File
+import kotlin.test.Test
import kotlin.test.assertEquals
+import kotlin.test.assertTrue
class ResolveLinkGfmCommandResolutionTest : MultiModuleAbstractTest() {
- @get:Rule
- val folder: TemporaryFolder = TemporaryFolder()
- private fun configuration() = dokkaConfiguration {
- modules = listOf(
- DokkaModuleDescriptionImpl(
- name = "module1",
- relativePathToOutputDirectory = folder.root.resolve("module1"),
- includes = emptySet(),
- sourceOutputDirectory = folder.root.resolve("module1"),
- ),
- DokkaModuleDescriptionImpl(
- name = "module2",
- relativePathToOutputDirectory = folder.root.resolve("module2"),
- includes = emptySet(),
- sourceOutputDirectory = folder.root.resolve("module2"),
+ @Test
+ fun `should resolve link to another module`(@TempDir outputDirectory: File) {
+ val configuration = dokkaConfiguration {
+ modules = listOf(
+ DokkaModuleDescriptionImpl(
+ name = "module1",
+ relativePathToOutputDirectory = outputDirectory.resolve("module1"),
+ includes = emptySet(),
+ sourceOutputDirectory = outputDirectory.resolve("module1"),
+ ),
+ DokkaModuleDescriptionImpl(
+ name = "module2",
+ relativePathToOutputDirectory = outputDirectory.resolve("module2"),
+ includes = emptySet(),
+ sourceOutputDirectory = outputDirectory.resolve("module2"),
+ )
)
- )
- outputDir = folder.root
- }
+ outputDir = outputDirectory
+ }
- @Test
- fun `should resolve link to another module`(){
- val testedDri = DRI(
- packageName = "package2",
- classNames = "Sample",
- )
+ val innerModule1 = outputDirectory.resolve("module1").also { assertTrue(it.mkdirs()) }
+ val innerModule2 = outputDirectory.resolve("module2").also { assertTrue(it.mkdirs()) }
+
+ val indexMd = innerModule1.resolve("index.md")
+ val packageList = innerModule2.resolve("package-list")
- val link = StringBuilder().apply {
- templateCommand(ResolveLinkGfmCommand(testedDri)){
+ val indexMdContent = StringBuilder().apply {
+ templateCommand(
+ ResolveLinkGfmCommand(
+ dri = DRI(
+ packageName = "package2",
+ classNames = "Sample",
+ )
+ )
+ ) {
append("Sample text inside")
}
}.toString()
- val expected = "[Sample text inside](../module2/package2/-sample/index.md)"
-
- val content = setup(link)
- val configuration = configuration()
+ indexMd.writeText(indexMdContent)
+ packageList.writeText(mockedPackageListForPackages(RecognizedLinkFormat.DokkaGFM, "package2"))
- testFromData(configuration, pluginOverrides = listOf(GfmTemplateProcessingPlugin(), GfmPlugin()), useOutputLocationFromConfig = true) {
+ testFromData(
+ configuration,
+ pluginOverrides = listOf(GfmTemplateProcessingPlugin(), GfmPlugin()),
+ useOutputLocationFromConfig = true
+ ) {
finishProcessingSubmodules = {
- assertEquals(expected, content.readText().trim())
+ val expectedIndexMd = "[Sample text inside](../module2/package2/-sample/index.md)"
+ assertEquals(expectedIndexMd, indexMd.readText().trim())
}
}
}
-
- private fun setup(content: String): File {
- folder.create()
- val innerModule1 = folder.newFolder( "module1")
- val innerModule2 = folder.newFolder( "module2")
- val packageList = innerModule2.resolve("package-list")
- packageList.writeText(mockedPackageListForPackages(RecognizedLinkFormat.DokkaGFM, "package2"))
- val contentFile = innerModule1.resolve("index.md")
- contentFile.writeText(content)
- return contentFile
- }
}