From 879d4f2652d528f20c95d5bb17899d6cb10c5e85 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Wed, 21 Sep 2022 13:14:51 +0200 Subject: Wrap long signatures dynamically based on client width (#2659) --- .../PageTransformerBuilderTest.kt | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt') 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 Collection.assertCount(n: Int, prefix: String = "") = assert(count() == n) { "${prefix}Expected $n, got ${count()}" } -- cgit