aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/signatures/DivergentSignatureTest.kt
blob: f03103d838e9f45db2ff143b31b623ee1cfca363 (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
67
package signatures

import org.junit.jupiter.api.Test
import utils.TestOutputWriterPlugin

class DivergentSignatureTest : AbstractRenderingTest() {

    @Test
    fun `group { common + jvm + js }`() {

        val writerPlugin = TestOutputWriterPlugin()

        testFromData(
            configuration,
            pluginOverrides = listOf(writerPlugin)
        ) {
            renderingStage = { _, _ ->
                val content = writerPlugin.renderedSourceDepenentContent("example/example/-clock/get-time.html")

                assert(content.count() == 3)
                val sourceSets = listOf("example/common", "example/js", "example/jvm")
                sourceSets.forEach {
                    assert(content.select("[data-togglable=$it]").single().brief == "")
                }
            }
        }
    }

    @Test
    fun `group { common + jvm }, group { js }`() {

        val writerPlugin = TestOutputWriterPlugin()

        testFromData(
            configuration,
            pluginOverrides = listOf(writerPlugin)
        ) {
            renderingStage = { _, _ ->
                val content = writerPlugin.renderedSourceDepenentContent("example/example/-clock/get-times-in-millis.html")

                assert(content.count() == 3)
                assert(content.select("[data-togglable=example/common]").single().brief == "Time in minis")
                assert(content.select("[data-togglable=example/jvm]").single().brief == "Time in minis")
                assert(content.select("[data-togglable=example/js]").single().brief == "JS implementation of getTimeInMillis" )
            }
        }
    }

    @Test
    fun `group { js }, group { jvm }, group { js }`() {

        val writerPlugin = TestOutputWriterPlugin()

        testFromData(
            configuration,
            pluginOverrides = listOf(writerPlugin)
        ) {
            renderingStage = { _, _ ->
                val content = writerPlugin.renderedSourceDepenentContent("example/example/-clock/get-year.html")
                assert(content.count() == 3)
                assert(content.select("[data-togglable=example/jvm]").single().brief == "JVM custom kdoc")
                assert(content.select("[data-togglable=example/js]").single().brief == "JS custom kdoc")
                assert(content.select("[data-togglable=example/common]").single().brief == "")
            }
        }
    }
}