aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt47
-rw-r--r--plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt36
2 files changed, 36 insertions, 47 deletions
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index 61c9556e..13e103b4 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -850,53 +850,6 @@ class SignatureTest : BaseAbstractTest() {
}
@Test
- fun `fun with single param should NOT have any wrapped or indented parameters`() {
- val source = source("fun assertNoIndent(int: Int): String = \"\"")
- val writerPlugin = TestOutputWriterPlugin()
-
- testInline(
- source,
- configuration,
- pluginOverrides = listOf(writerPlugin)
- ) {
- renderingStage = { _, _ ->
- val signature = writerPlugin.writer.renderedContent("root/example/assert-no-indent.html").firstSignature()
- signature.match(
- "fun", A("assertNoIndent"), "(", Parameters(
- Parameter("int: ", A("Int")),
- ), "): ", A("String"),
- ignoreSpanWithTokenStyle = true
- )
- assertFalse { signature.select("span.parameters").single().hasClass("wrapped") }
- assertFalse { signature.select("span.parameters > span.parameter").single().hasClass("indented") }
- }
- }
- }
-
- @Test
- fun `fun with many params should have wrapped and indented parameters`() {
- val source = source("fun assertParamsIndent(int: Int, string: String, long: Long): String = \"\"")
- val writerPlugin = TestOutputWriterPlugin()
-
- testInline(
- source,
- configuration,
- pluginOverrides = listOf(writerPlugin)
- ) {
- renderingStage = { _, _ ->
- writerPlugin.writer.renderedContent("root/example/assert-params-indent.html").firstSignature().match(
- "fun", A("assertParamsIndent"), "(", Parameters(
- Parameter("int: ", A("Int"), ",").withClasses("indented"),
- Parameter("string: ", A("String"), ",").withClasses("indented"),
- Parameter("long: ", A("Long")).withClasses("indented")
- ).withClasses("wrapped"), "): ", A("String"),
- ignoreSpanWithTokenStyle = true
- )
- }
- }
- }
-
- @Test
fun `const val with default values`() {
val source = source("const val simpleVal = 1")
val writerPlugin = TestOutputWriterPlugin()
diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
index 8685e3c9..67e4d16f 100644
--- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
+++ b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
@@ -8,7 +8,10 @@ import org.jetbrains.dokka.transformers.pages.PageTransformer
import org.jetbrains.dokka.transformers.pages.pageMapper
import org.jetbrains.dokka.transformers.pages.pageScanner
import org.jetbrains.dokka.transformers.pages.pageStructureTransformer
+import org.jsoup.Jsoup
import org.junit.jupiter.api.Test
+import utils.TestOutputWriterPlugin
+import utils.assertContains
import kotlin.test.assertEquals
class PageTransformerBuilderTest : BaseAbstractTest() {
@@ -168,6 +171,39 @@ class PageTransformerBuilderTest : BaseAbstractTest() {
}
}
+ @Test
+ fun `should load script as defer if name ending in _deferred`() {
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/main/kotlin")
+ }
+ }
+ }
+ val writerPlugin = TestOutputWriterPlugin()
+ testInline(
+ """
+ |/src/main/kotlin/test/Test.kt
+ |package test
+ |
+ |class Test
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val generatedFiles = writerPlugin.writer.contents
+
+ assertContains(generatedFiles.keys, "scripts/symbol-parameters-wrapper_deferred.js")
+
+ val scripts = generatedFiles.getValue("root/test/-test/-test.html").let { Jsoup.parse(it) }.select("script")
+ val deferredScriptSources = scripts.filter { it.hasAttr("defer") }.map { it.attr("src") }
+
+ // important to check symbol-parameters-wrapper_deferred specifically since it might break some features
+ assertContains(deferredScriptSources, "../../../scripts/symbol-parameters-wrapper_deferred.js")
+ }
+ }
+ }
private fun <T> Collection<T>.assertCount(n: Int, prefix: String = "") =
assert(count() == n) { "${prefix}Expected $n, got ${count()}" }