aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-01-14 16:51:25 +0100
committerGitHub <noreply@github.com>2021-01-14 16:51:25 +0100
commitc04295aa7f0bdad9eb7b27e3dbc2b2c90094da86 (patch)
tree92952ccc055b3d466e85c9998d6ea5349d5c1ce2 /plugins/base/src/test
parent4a0af562bc86ebb84ecd8a90f690214c79df8d40 (diff)
downloaddokka-c04295aa7f0bdad9eb7b27e3dbc2b2c90094da86.tar.gz
dokka-c04295aa7f0bdad9eb7b27e3dbc2b2c90094da86.tar.bz2
dokka-c04295aa7f0bdad9eb7b27e3dbc2b2c90094da86.zip
Footer customisation (#1691)
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/CustomFooterTest.kt44
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/FooterMessageTest.kt27
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt9
3 files changed, 77 insertions, 3 deletions
diff --git a/plugins/base/src/test/kotlin/renderers/html/CustomFooterTest.kt b/plugins/base/src/test/kotlin/renderers/html/CustomFooterTest.kt
new file mode 100644
index 00000000..c1ef6121
--- /dev/null
+++ b/plugins/base/src/test/kotlin/renderers/html/CustomFooterTest.kt
@@ -0,0 +1,44 @@
+package renderers.html
+
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaConfigurationImpl
+import org.jetbrains.dokka.PluginConfigurationImpl
+import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.DokkaBaseConfiguration
+import org.jetbrains.dokka.base.renderers.html.HtmlRenderer
+import org.jetbrains.dokka.base.templating.toJsonString
+import org.jsoup.Jsoup
+import org.jsoup.nodes.Element
+import org.junit.jupiter.api.Test
+import renderers.testPage
+import utils.A
+import utils.Div
+import utils.Span
+import utils.match
+
+class CustomFooterTest : HtmlRenderingOnlyTestBase() {
+ @Test
+ fun `should include message from custom footer`() {
+ val page = testPage { }
+ HtmlRenderer(context).render(page)
+ renderedContent.match(
+ Span(A()),
+ Span(Div("Custom message")),
+ Span(Span("Generated by "), A(Span("dokka"), Span()))
+ )
+ }
+
+ override val configuration: DokkaConfigurationImpl
+ get() = super.configuration.copy(
+ pluginsConfiguration = listOf(
+ PluginConfigurationImpl(
+ DokkaBase::class.java.canonicalName,
+ DokkaConfiguration.SerializationFormat.JSON,
+ toJsonString(DokkaBaseConfiguration(footerMessage = """<div style="color: red">Custom message</div>"""))
+ )
+ )
+ )
+
+ override val renderedContent: Element
+ get() = files.contents.getValue("test-page.html").let { Jsoup.parse(it) }.select(".footer").single()
+} \ No newline at end of file
diff --git a/plugins/base/src/test/kotlin/renderers/html/FooterMessageTest.kt b/plugins/base/src/test/kotlin/renderers/html/FooterMessageTest.kt
new file mode 100644
index 00000000..d91c402e
--- /dev/null
+++ b/plugins/base/src/test/kotlin/renderers/html/FooterMessageTest.kt
@@ -0,0 +1,27 @@
+package renderers.html
+
+import org.jetbrains.dokka.base.DokkaBaseConfiguration.Companion.defaultFooterMessage
+import org.jetbrains.dokka.base.renderers.html.HtmlRenderer
+import org.jsoup.Jsoup
+import org.jsoup.nodes.Element
+import org.junit.jupiter.api.Test
+import renderers.testPage
+import utils.A
+import utils.Span
+import utils.match
+
+class FooterMessageTest : HtmlRenderingOnlyTestBase() {
+ @Test
+ fun `should include defaultFooter`() {
+ val page = testPage { }
+ HtmlRenderer(context).render(page)
+ renderedContent.match(
+ Span(A()),
+ Span(defaultFooterMessage),
+ Span(Span("Generated by "), A(Span("dokka"), Span()))
+ )
+ }
+
+ override val renderedContent: Element
+ get() = files.contents.getValue("test-page.html").let { Jsoup.parse(it) }.select(".footer").single()
+} \ No newline at end of file
diff --git a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
index 71d141e2..9b88a170 100644
--- a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
@@ -41,6 +41,11 @@ abstract class HtmlRenderingOnlyTestBase : RenderingOnlyTestBase<Element>() {
)
val files = TestOutputWriter()
+
+ open val configuration = DokkaConfigurationImpl(
+ sourceSets = listOf(js, jvm, native)
+ )
+
override val context = MockContext(
DokkaBase().outputWriter to { _ -> files },
DokkaBase().locationProviderFactory to ::DokkaLocationProviderFactory,
@@ -48,9 +53,7 @@ abstract class HtmlRenderingOnlyTestBase : RenderingOnlyTestBase<Element>() {
DokkaBase().externalLocationProviderFactory to { ::JavadocExternalLocationProviderFactory },
DokkaBase().externalLocationProviderFactory to { ::DefaultExternalLocationProviderFactory },
DokkaBase().tabSortingStrategy to { DefaultTabSortingStrategy() },
- testConfiguration = DokkaConfigurationImpl(
- sourceSets = listOf(js, jvm, native)
- )
+ testConfiguration = configuration
)
override val renderedContent: Element by lazy {