aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/signatures/RawHtmlRenderingTest.kt
blob: 38c70cd42cb4bd8feecaef7ed106a29796cfb598 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package signatures

import org.jsoup.Jsoup
import org.junit.jupiter.api.Test
import utils.TestOutputWriterPlugin
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class RawHtmlRenderingTest: AbstractRenderingTest() {
    @Test
    fun `work with raw html with inline comment`() {
        val writerPlugin = TestOutputWriterPlugin()

        testFromData(
            configuration,
            pluginOverrides = listOf(writerPlugin)
        ) {
            renderingStage = { _, _ ->
                val content = writerPlugin.renderedSourceDependentContent("example/example/-html-test/test.html")
                assert(content.count() == 1)
                assertEquals(content.select("[data-togglable=example/jvm]").single().rawBrief,"This is an example <!-- not visible --> of html")

                val indexContent = writerPlugin.writer.contents.getValue("example/example/-html-test/index.html")
                    .let { Jsoup.parse(it) }
                assertTrue(indexContent.select("div.brief").any { it.html().contains("This is an example <!-- not visible --> of html")})
            }
        }
    }

    @Test
    fun `work with raw html`() {
        val writerPlugin = TestOutputWriterPlugin()

        testFromData(
            configuration,
            pluginOverrides = listOf(writerPlugin)
        ) {
            renderingStage = { _, _ ->
                //Module page
                val content = writerPlugin.renderedContent("example/example/index.html").select("div.brief")
                assertTrue(content.size > 0)
                assertTrue(content.any { it.html().contains("<!-- this shouldn't be visible -->")})
            }
        }
    }

    @Test
    fun `work with raw, visible html`() {
        val writerPlugin = TestOutputWriterPlugin()

        testFromData(
            configuration,
            pluginOverrides = listOf(writerPlugin)
        ) {
            renderingStage = { _, _ ->
                val content = writerPlugin.renderedSourceDependentContent("example/example/-html-test/test-p.html")
                assert(content.count() == 1)
                assertEquals(content.select("[data-togglable=example/jvm]").single().rawBrief, "This is an <b> documentation </b>")

                val indexContent = writerPlugin.writer.contents.getValue("example/example/-html-test/index.html")
                    .let { Jsoup.parse(it) }
                assertTrue(indexContent.select("div.brief").any { it.html().contains("This is an <b> documentation </b>")})
            }
        }
    }
}