aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/renderers/html/CustomFooterTest.kt
blob: c1ef612159acf8dffff263b70fdb8ef1bfb7d9c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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()
}