aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/format
diff options
context:
space:
mode:
authoraleksZubakov <aleks.zubakov@gmail.com>2018-07-12 20:23:02 +0300
committeraleksZubakov <aleks.zubakov@gmail.com>2018-07-12 20:23:02 +0300
commit742be4ef7c024a5ea6023fb684cd24d1898f37e4 (patch)
tree34fc44ef7ee5afdb7a153367d80872f74ace4937 /core/src/test/kotlin/format
parentb4fcc57ab7f335459131ce105924eeaa5fa77375 (diff)
downloaddokka-742be4ef7c024a5ea6023fb684cd24d1898f37e4.tar.gz
dokka-742be4ef7c024a5ea6023fb684cd24d1898f37e4.tar.bz2
dokka-742be4ef7c024a5ea6023fb684cd24d1898f37e4.zip
Test refactoring, add common platform tests
Diffstat (limited to 'core/src/test/kotlin/format')
-rw-r--r--core/src/test/kotlin/format/GFMFormatTest.kt18
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt (renamed from core/src/test/kotlin/format/BaseHtmlFormatTest.kt)47
-rw-r--r--core/src/test/kotlin/format/JSHtmlFormatTest.kt6
-rw-r--r--core/src/test/kotlin/format/JSMarkdownFormatTest.kt7
-rw-r--r--core/src/test/kotlin/format/JVMHtmlFormatTest.kt54
-rw-r--r--core/src/test/kotlin/format/JVMMarkdownFormatTest.kt117
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt29
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt (renamed from core/src/test/kotlin/format/BaseMarkdownFormatTest.kt)113
8 files changed, 192 insertions, 199 deletions
diff --git a/core/src/test/kotlin/format/GFMFormatTest.kt b/core/src/test/kotlin/format/GFMFormatTest.kt
index b90ab2bf..60de7d29 100644
--- a/core/src/test/kotlin/format/GFMFormatTest.kt
+++ b/core/src/test/kotlin/format/GFMFormatTest.kt
@@ -2,23 +2,26 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.GFMFormatService
import org.jetbrains.dokka.KotlinLanguageService
+import org.jetbrains.dokka.Platform
import org.junit.Test
-class GFMFormatTest : FileGeneratorTestCase() {
+abstract class BaseGFMFormatTest(val analysisPlatform: Platform) : FileGeneratorTestCase() {
override val formatService = GFMFormatService(fileGenerator, KotlinLanguageService(), listOf())
+ private val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
+
@Test
fun sample() {
- verifyGFMNodeByName("sample", "Foo")
+ verifyGFMNodeByName("sample", "Foo", defaultModelConfig)
}
@Test
fun listInTableCell() {
- verifyGFMNodeByName("listInTableCell", "Foo")
+ verifyGFMNodeByName("listInTableCell", "Foo", defaultModelConfig)
}
- private fun verifyGFMNodeByName(fileName: String, name: String) {
- verifyOutput("testdata/format/gfm/$fileName.kt", ".md") { model, output ->
+ private fun verifyGFMNodeByName(fileName: String, name: String, modelConfig: ModelConfig) {
+ verifyOutput("testdata/format/gfm/$fileName.kt", ".md", modelConfig) { model, output ->
buildPagesAndReadInto(
model.members.single().members.filter { it.name == name },
output
@@ -26,3 +29,8 @@ class GFMFormatTest : FileGeneratorTestCase() {
}
}
}
+
+
+class JsGFMFormatTest : BaseGFMFormatTest(Platform.js)
+class JvmGFMFormatTest : BaseGFMFormatTest(Platform.jvm)
+class CommonGFMFormatTest : BaseGFMFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/BaseHtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt
index 7fd331cf..20891963 100644
--- a/core/src/test/kotlin/format/BaseHtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/HtmlFormatTest.kt
@@ -144,3 +144,50 @@ abstract class BaseHtmlFormatTest(val analysisPlatform: Platform): FileGenerator
}
}
+class JSHtmlFormatTest: BaseHtmlFormatTest(Platform.js)
+
+class JVMHtmlFormatTest: BaseHtmlFormatTest(Platform.jvm) {
+ @Test
+ fun javaSeeTag() {
+ verifyJavaHtmlNode("javaSeeTag", defaultModelConfig)
+ }
+
+ @Test fun javaDeprecated() {
+ verifyJavaHtmlNodes("javaDeprecated", defaultModelConfig) { model ->
+ model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }
+ }
+ }
+
+ @Test fun crossLanguageKotlinExtendsJava() {
+ verifyOutput(
+ ModelConfig(
+ roots = arrayOf(
+ KotlinSourceRoot("testdata/format/crossLanguage/kotlinExtendsJava/Bar.kt"),
+ JavaSourceRoot(File("testdata/format/crossLanguage/kotlinExtendsJava"), null)
+ ),
+ analysisPlatform = analysisPlatform
+ ), ".html") { model, output ->
+ buildPagesAndReadInto(
+ model.members.single().members.filter { it.name == "Bar" },
+ output
+ )
+ }
+ }
+
+ @Test fun javaLinkTag() {
+ verifyJavaHtmlNode("javaLinkTag", defaultModelConfig)
+ }
+
+ @Test fun javaLinkTagWithLabel() {
+ verifyJavaHtmlNode("javaLinkTagWithLabel", defaultModelConfig)
+ }
+
+ @Test fun javaSupertypeLink() {
+ verifyJavaHtmlNodes("JavaSupertype", defaultModelConfig) { model ->
+ model.members.single().members.single { it.name == "JavaSupertype" }.members.filter { it.name == "Bar" }
+ }
+ }
+
+}
+
+class CommonHtmlFormatTest: BaseHtmlFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/JSHtmlFormatTest.kt b/core/src/test/kotlin/format/JSHtmlFormatTest.kt
deleted file mode 100644
index afa0ce0a..00000000
--- a/core/src/test/kotlin/format/JSHtmlFormatTest.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.jetbrains.dokka.tests.format
-
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BaseHtmlFormatTest
-
-class JSHtmlFormatTest: BaseHtmlFormatTest(Platform.js) {} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/JSMarkdownFormatTest.kt b/core/src/test/kotlin/format/JSMarkdownFormatTest.kt
deleted file mode 100644
index ca92d9f6..00000000
--- a/core/src/test/kotlin/format/JSMarkdownFormatTest.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.jetbrains.dokka.tests.format
-
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BaseMarkdownFormatTest
-
-class JSMarkdownFormatTest: BaseMarkdownFormatTest(Platform.js) {
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/JVMHtmlFormatTest.kt b/core/src/test/kotlin/format/JVMHtmlFormatTest.kt
deleted file mode 100644
index 1696ffb2..00000000
--- a/core/src/test/kotlin/format/JVMHtmlFormatTest.kt
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.jetbrains.dokka.tests.format
-
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BaseHtmlFormatTest
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.verifyOutput
-import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
-import org.jetbrains.kotlin.config.KotlinSourceRoot
-import org.junit.Test
-import java.io.File
-
-class JVMHtmlFormatTest: BaseHtmlFormatTest(Platform.jvm) {
- @Test
- fun javaSeeTag() {
- verifyJavaHtmlNode("javaSeeTag", defaultModelConfig)
- }
-
- @Test fun javaDeprecated() {
- verifyJavaHtmlNodes("javaDeprecated", defaultModelConfig) { model ->
- model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }
- }
- }
-
- @Test fun crossLanguageKotlinExtendsJava() {
- verifyOutput(
- ModelConfig(
- roots = arrayOf(
- KotlinSourceRoot("testdata/format/crossLanguage/kotlinExtendsJava/Bar.kt"),
- JavaSourceRoot(File("testdata/format/crossLanguage/kotlinExtendsJava"), null)
- ),
- analysisPlatform = analysisPlatform
- ), ".html") { model, output ->
- buildPagesAndReadInto(
- model.members.single().members.filter { it.name == "Bar" },
- output
- )
- }
- }
-
- @Test fun javaLinkTag() {
- verifyJavaHtmlNode("javaLinkTag", defaultModelConfig)
- }
-
- @Test fun javaLinkTagWithLabel() {
- verifyJavaHtmlNode("javaLinkTagWithLabel", defaultModelConfig)
- }
-
- @Test fun javaSupertypeLink() {
- verifyJavaHtmlNodes("JavaSupertype", defaultModelConfig) { model ->
- model.members.single().members.single { it.name == "JavaSupertype" }.members.filter { it.name == "Bar" }
- }
- }
-
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt b/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt
deleted file mode 100644
index ee8169af..00000000
--- a/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.jetbrains.dokka.tests.format
-
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.contentRootFromPath
-import org.jetbrains.dokka.tests.BaseMarkdownFormatTest
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.verifyOutput
-import org.junit.Test
-
-class JVMMarkdownFormatTest: BaseMarkdownFormatTest(Platform.jvm) {
-
- @Test
- fun enumRef() {
- verifyMarkdownNode("enumRef", defaultModelConfig)
- }
-
- @Test
- fun javaCodeLiteralTags() {
- verifyJavaMarkdownNode("javaCodeLiteralTags", defaultModelConfig)
- }
-
- @Test
- fun nullability() {
- verifyMarkdownNode("nullability", defaultModelConfig)
- }
-
- @Test
- fun exceptionClass() {
- verifyMarkdownNode(
- "exceptionClass", ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- )
- verifyMarkdownPackage(
- "exceptionClass", ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- )
- }
-
- @Test
- fun operatorOverloading() {
- verifyMarkdownNodes("operatorOverloading", defaultModelConfig) { model->
- model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }
- }
- }
-
- @Test
- fun extensions() {
- verifyOutput("testdata/format/extensions.kt", ".package.md", defaultModelConfig) { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- verifyOutput("testdata/format/extensions.kt", ".class.md", defaultModelConfig) { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test
- fun summarizeSignaturesProperty() {
- verifyMarkdownNodes("summarizeSignaturesProperty", defaultModelConfig) { model -> model.members }
- }
-
- @Test
- fun javaSpaceInAuthor() {
- verifyJavaMarkdownNode("javaSpaceInAuthor", defaultModelConfig)
- }
-
- @Test
- fun javaCodeInParam() {
- verifyJavaMarkdownNode("javaCodeInParam", defaultModelConfig)
- }
-
- @Test
- fun annotationParams() {
- verifyMarkdownNode("annotationParams", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
- }
-
- @Test fun inheritedLink() {
- val filePath = "testdata/format/inheritedLink"
- verifyOutput(
- filePath,
- ".md",
- ModelConfig(
- roots = arrayOf(
- contentRootFromPath("$filePath.kt"),
- contentRootFromPath("$filePath.1.kt")
- ),
- withJdk = true,
- withKotlinRuntime = true,
- includeNonPublic = false,
- analysisPlatform = analysisPlatform
-
- )
- ) { model, output ->
- buildPagesAndReadInto(model.members.single { it.name == "p2" }.members.single().members, output)
- }
- }
-
- @Test
- fun javadocOrderedList() {
- verifyJavaMarkdownNodes("javadocOrderedList", defaultModelConfig) { model ->
- model.members.single().members.filter { it.name == "Bar" }
- }
- }
-
- @Test
- fun jdkLinks() {
- verifyMarkdownNode("jdkLinks", ModelConfig(withKotlinRuntime = true, analysisPlatform = analysisPlatform))
- }
-
- @Test
- fun javadocHtml() {
- verifyJavaMarkdownNode("javadocHtml", defaultModelConfig)
- }
-}
diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
index c02d3ad4..5df43017 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
@@ -3,35 +3,36 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
import org.junit.Test
-class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() {
+abstract class BaseKotlinWebSiteHtmlFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
+ val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
override val formatService = KotlinWebsiteHtmlFormatService(fileGenerator, KotlinLanguageService(), listOf(), EmptyHtmlTemplateService)
@Test fun dropImport() {
- verifyKWSNodeByName("dropImport", "foo")
+ verifyKWSNodeByName("dropImport", "foo", defaultModelConfig)
}
@Test fun sample() {
- verifyKWSNodeByName("sample", "foo")
+ verifyKWSNodeByName("sample", "foo", defaultModelConfig)
}
@Test fun sampleWithAsserts() {
- verifyKWSNodeByName("sampleWithAsserts", "a")
+ verifyKWSNodeByName("sampleWithAsserts", "a", defaultModelConfig)
}
@Test fun newLinesInSamples() {
- verifyKWSNodeByName("newLinesInSamples", "foo")
+ verifyKWSNodeByName("newLinesInSamples", "foo", defaultModelConfig)
}
@Test fun newLinesInImportList() {
- verifyKWSNodeByName("newLinesInImportList", "foo")
+ verifyKWSNodeByName("newLinesInImportList", "foo", defaultModelConfig)
}
@Test fun returnTag() {
- verifyKWSNodeByName("returnTag", "indexOf")
+ verifyKWSNodeByName("returnTag", "indexOf", defaultModelConfig)
}
@Test fun overloadGroup() {
- verifyKWSNodeByName("overloadGroup", "magic")
+ verifyKWSNodeByName("overloadGroup", "magic", defaultModelConfig)
}
@Test fun dataTags() {
@@ -51,8 +52,12 @@ class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() {
verifyMultiplatformPackage(module, path)
}
- private fun verifyKWSNodeByName(fileName: String, name: String) {
- verifyOutput("testdata/format/website-html/$fileName.kt", ".html", ModelConfig(format = "kotlin-website-html")) { model, output ->
+ private fun verifyKWSNodeByName(fileName: String, name: String, modelConfig: ModelConfig) {
+ verifyOutput(
+ "testdata/format/website-html/$fileName.kt",
+ ".html",
+ ModelConfig(analysisPlatform = modelConfig.analysisPlatform, format = "kotlin-website-html")
+ ) { model, output ->
buildPagesAndReadInto(model.members.single().members.filter { it.name == name }, output)
}
}
@@ -96,3 +101,7 @@ class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() {
}
}
+
+class JsKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.js)
+class JvmKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.jvm)
+class CommonKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/BaseMarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 5612b1fd..6c62587b 100644
--- a/core/src/test/kotlin/format/BaseMarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -465,3 +465,116 @@ abstract class BaseMarkdownFormatTest(val analysisPlatform: Platform): FileGener
}
}
}
+
+class JSMarkdownFormatTest: BaseMarkdownFormatTest(Platform.js)
+
+class JVMMarkdownFormatTest: BaseMarkdownFormatTest(Platform.jvm) {
+
+ @Test
+ fun enumRef() {
+ verifyMarkdownNode("enumRef", defaultModelConfig)
+ }
+
+ @Test
+ fun javaCodeLiteralTags() {
+ verifyJavaMarkdownNode("javaCodeLiteralTags", defaultModelConfig)
+ }
+
+ @Test
+ fun nullability() {
+ verifyMarkdownNode("nullability", defaultModelConfig)
+ }
+
+ @Test
+ fun exceptionClass() {
+ verifyMarkdownNode(
+ "exceptionClass", ModelConfig(
+ analysisPlatform = analysisPlatform,
+ withKotlinRuntime = true
+ )
+ )
+ verifyMarkdownPackage(
+ "exceptionClass", ModelConfig(
+ analysisPlatform = analysisPlatform,
+ withKotlinRuntime = true
+ )
+ )
+ }
+
+ @Test
+ fun operatorOverloading() {
+ verifyMarkdownNodes("operatorOverloading", defaultModelConfig) { model->
+ model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }
+ }
+ }
+
+ @Test
+ fun extensions() {
+ verifyOutput("testdata/format/extensions.kt", ".package.md", defaultModelConfig) { model, output ->
+ buildPagesAndReadInto(model.members, output)
+ }
+ verifyOutput("testdata/format/extensions.kt", ".class.md", defaultModelConfig) { model, output ->
+ buildPagesAndReadInto(model.members.single().members, output)
+ }
+ }
+
+ @Test
+ fun summarizeSignaturesProperty() {
+ verifyMarkdownNodes("summarizeSignaturesProperty", defaultModelConfig) { model -> model.members }
+ }
+
+ @Test
+ fun javaSpaceInAuthor() {
+ verifyJavaMarkdownNode("javaSpaceInAuthor", defaultModelConfig)
+ }
+
+ @Test
+ fun javaCodeInParam() {
+ verifyJavaMarkdownNode("javaCodeInParam", defaultModelConfig)
+ }
+
+ @Test
+ fun annotationParams() {
+ verifyMarkdownNode("annotationParams", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
+ }
+
+ @Test fun inheritedLink() {
+ val filePath = "testdata/format/inheritedLink"
+ verifyOutput(
+ filePath,
+ ".md",
+ ModelConfig(
+ roots = arrayOf(
+ contentRootFromPath("$filePath.kt"),
+ contentRootFromPath("$filePath.1.kt")
+ ),
+ withJdk = true,
+ withKotlinRuntime = true,
+ includeNonPublic = false,
+ analysisPlatform = analysisPlatform
+
+ )
+ ) { model, output ->
+ buildPagesAndReadInto(model.members.single { it.name == "p2" }.members.single().members, output)
+ }
+ }
+
+ @Test
+ fun javadocOrderedList() {
+ verifyJavaMarkdownNodes("javadocOrderedList", defaultModelConfig) { model ->
+ model.members.single().members.filter { it.name == "Bar" }
+ }
+ }
+
+ @Test
+ fun jdkLinks() {
+ verifyMarkdownNode("jdkLinks", ModelConfig(withKotlinRuntime = true, analysisPlatform = analysisPlatform))
+ }
+
+ @Test
+ fun javadocHtml() {
+ verifyJavaMarkdownNode("javadocHtml", defaultModelConfig)
+ }
+}
+
+class CommonMarkdownFormatTest: BaseMarkdownFormatTest(Platform.common) \ No newline at end of file