aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/model/DocumentableTest.kt
blob: 56d32bb2b364d3c74b283736e2376bca9dfe68d2 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package model

import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.PropertyContainer
import kotlin.test.Test
import kotlin.test.assertEquals

class DocumentableTest {

    @Test
    fun withDescendents() {
        val dClass = DClass(
            dri = DRI(),
            name = "TestClass",
            constructors = emptyList(),
            classlikes = emptyList(),
            companion = null,
            documentation = emptyMap(),
            expectPresentInSet = null,
            extra = PropertyContainer.empty(),
            visibility = emptyMap(),
            generics = emptyList(),
            modifier = emptyMap(),
            properties = emptyList(),
            sources = emptyMap(),
            sourceSets = emptySet(),
            supertypes = emptyMap(),
            isExpectActual = false,
            functions = listOf(
                DFunction(
                    dri = DRI(),
                    name = "function0",
                    documentation = emptyMap(),
                    expectPresentInSet = null,
                    extra = PropertyContainer.empty(),
                    visibility = emptyMap(),
                    generics = emptyList(),
                    modifier = emptyMap(),
                    sources = emptyMap(),
                    sourceSets = emptySet(),
                    type = Void,
                    receiver = null,
                    isConstructor = false,
                    isExpectActual = false,
                    parameters = listOf(
                        DParameter(
                            dri = DRI(),
                            name = "f0p0",
                            documentation = emptyMap(),
                            expectPresentInSet = null,
                            extra = PropertyContainer.empty(),
                            sourceSets = emptySet(),
                            type = Void
                        ),
                        DParameter(
                            dri = DRI(),
                            name = "f0p1",
                            documentation = emptyMap(),
                            expectPresentInSet = null,
                            extra = PropertyContainer.empty(),
                            sourceSets = emptySet(),
                            type = Void
                        )
                    )
                ),
                DFunction(
                    dri = DRI(),
                    name = "function1",
                    documentation = emptyMap(),
                    expectPresentInSet = null,
                    extra = PropertyContainer.empty(),
                    visibility = emptyMap(),
                    generics = emptyList(),
                    modifier = emptyMap(),
                    sources = emptyMap(),
                    sourceSets = emptySet(),
                    type = Void,
                    receiver = null,
                    isConstructor = false,
                    isExpectActual = false,
                    parameters = listOf(
                        DParameter(
                            dri = DRI(),
                            name = "f1p0",
                            documentation = emptyMap(),
                            expectPresentInSet = null,
                            extra = PropertyContainer.empty(),
                            sourceSets = emptySet(),
                            type = Void
                        ),
                        DParameter(
                            dri = DRI(),
                            name = "f1p1",
                            documentation = emptyMap(),
                            expectPresentInSet = null,
                            extra = PropertyContainer.empty(),
                            sourceSets = emptySet(),
                            type = Void
                        )
                    )
                )
            )
        )

        assertEquals(
            listOf("TestClass", "function0", "f0p0", "f0p1", "function1", "f1p0", "f1p1"),
            dClass.withDescendants().map { it.name }.toList()
        )
    }
}