aboutsummaryrefslogtreecommitdiff
path: root/dokka-subprojects/plugin-base/src/test/kotlin/content/functions/ContentForConstructors.kt
blob: d1ed93dcb04078fcb521db09690a1eb1fb529cc8 (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
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package content.functions

import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.model.DClass
import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import utils.assertContains
import utils.assertNotNull
import kotlin.test.Test
import kotlin.test.assertEquals

class ContentForConstructors : BaseAbstractTest() {
    private val testConfiguration = dokkaConfiguration {
        sourceSets {
            sourceSet {
                sourceRoots = listOf("src/")
                analysisPlatform = "jvm"
            }
        }
    }

    @Test
    fun `constructor name should have RowTitle style`() {
        testInline("""
            |/src/main/kotlin/test/source.kt
            |package test
            |
            |/**
            | * Dummy text.
            | */
            |class Example(val exampleParameter: Int) {
            |}
        """.trimIndent(), testConfiguration) {
            pagesTransformationStage = { module ->
                val classPage =
                    module.dfs { it.name == "Example" && (it as WithDocumentables).documentables.firstOrNull() is DClass } as ContentPage
                val constructorsTable =
                    classPage.content.dfs { it is ContentTable && it.dci.kind == ContentKind.Constructors } as ContentTable

                assertEquals(1, constructorsTable.children.size)
                val primary = constructorsTable.children.first()
                val constructorName =
                    primary.dfs { (it as? ContentText)?.text == "Example" }.assertNotNull("constructorName")

                assertContains(constructorName.style, ContentStyle.RowTitle)
            }
        }
    }
}