aboutsummaryrefslogtreecommitdiff
path: root/dokka-subprojects/plugin-base/src/test/kotlin/signatures/DivergentSignatureTest.kt
blob: 509dd6e75e4d0f448535d61d49ca41969f28d3c6 (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
68
69
70
71
72
73
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package signatures

import utils.TestOutputWriterPlugin
import kotlin.test.Test
import kotlin.test.assertEquals


class DivergentSignatureTest : AbstractRenderingTest() {

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

        val writerPlugin = TestOutputWriterPlugin()

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

                assertEquals(3, content.count())
                val sourceSets = listOf("example/common", "example/js", "example/jvm")
                sourceSets.forEach {
                    assertEquals("", 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.renderedSourceDependentContent("example/example/-clock/get-times-in-millis.html")

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

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

        val writerPlugin = TestOutputWriterPlugin()

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