diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-06-30 14:19:06 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-01 09:43:03 +0200 |
commit | 1bd0cba71db2330a5e827860c4fa8c5b7eda12b4 (patch) | |
tree | bdf6bbd7966497ebeb0e54a0dc75518cdc58a492 /plugins/javadoc | |
parent | 0b2071d7a4483a854ed0b3ee63f7bb81807014bf (diff) | |
download | dokka-1bd0cba71db2330a5e827860c4fa8c5b7eda12b4.tar.gz dokka-1bd0cba71db2330a5e827860c4fa8c5b7eda12b4.tar.bz2 dokka-1bd0cba71db2330a5e827860c4fa8c5b7eda12b4.zip |
Implement simple JavadocAllClassesTemplateMapTest.kt
Diffstat (limited to 'plugins/javadoc')
-rw-r--r-- | plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt | 15 | ||||
-rw-r--r-- | plugins/javadoc/src/test/kotlin/javadoc/JavadocAllClassesTemplateMapTest.kt | 49 |
2 files changed, 60 insertions, 4 deletions
diff --git a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt index 6cae821d..138208ae 100644 --- a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt @@ -1,6 +1,7 @@ package javadoc import javadoc.pages.JavadocPageNode +import javadoc.pages.preprocessors import javadoc.renderer.JavadocContentToTemplateMapTranslator import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.javadoc.JavadocPlugin @@ -61,7 +62,12 @@ internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() { ) { testInline(query, configuration) { renderingStage = { rootPageNode, dokkaContext -> - Result(rootPageNode, dokkaContext).assertions() + // TODO NOW: Clarify preprocessors! + val transformedRootPageNode = preprocessors.fold(rootPageNode) { acc, pageTransformer -> + pageTransformer(acc) + } + + Result(transformedRootPageNode, dokkaContext).assertions() } } } @@ -93,9 +99,10 @@ internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() { } if (kotlinException != null && javaException != null) { - throw AssertionError("Kotlin and Java Code failed assertions\n" + - "Kotlin: ${kotlinException.message}\n" + - "Java: ${javaException.message}", + throw AssertionError( + "Kotlin and Java Code failed assertions\n" + + "Kotlin: ${kotlinException.message}\n" + + "Java: ${javaException.message}", kotlinException ) } diff --git a/plugins/javadoc/src/test/kotlin/javadoc/JavadocAllClassesTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/JavadocAllClassesTemplateMapTest.kt new file mode 100644 index 00000000..314ba0a3 --- /dev/null +++ b/plugins/javadoc/src/test/kotlin/javadoc/JavadocAllClassesTemplateMapTest.kt @@ -0,0 +1,49 @@ +package javadoc + +import javadoc.pages.AllClassesPage +import javadoc.pages.LinkJavadocListEntry +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.pages.ContentKind +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import testApi.utils.assertIsInstance + +internal class JavadocAllClassesTemplateMapTest : AbstractJavadocTemplateMapTest() { + @Test + fun `two classes from different packages`() { + dualTestTemplateMapInline( + """ + /src/source0.kt + package package0 + /** + * Documentation for ClassA + */ + class ClassA + + /src/source1.kt + package package1 + /** + * Documentation for ClassB + */ + class ClassB + """ + ) { + val map = singlePageOfType<AllClassesPage>().templateMap + assertEquals("main", map["kind"]) + assertEquals("All Classes", map["title"]) + + val list = assertIsInstance<List<*>>(map["list"]) + assertEquals(2, list.size, "Expected two classes") + + val classA = assertIsInstance<LinkJavadocListEntry>(list[0]) + assertEquals("ClassA", classA.name) + assertEquals(DRI("package0", "ClassA"), classA.dri.single()) + assertEquals(ContentKind.Classlikes, classA.kind) + + val classB = assertIsInstance<LinkJavadocListEntry>(list[1]) + assertEquals("ClassB", classB.name) + assertEquals(DRI("package1", "ClassB"), classB.dri.single()) + assertEquals(ContentKind.Classlikes, classB.kind) + } + } +} |