From 1bd0cba71db2330a5e827860c4fa8c5b7eda12b4 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Tue, 30 Jun 2020 14:19:06 +0200 Subject: Implement simple JavadocAllClassesTemplateMapTest.kt --- .../javadoc/AbstractJavadocTemplateMapTest.kt | 15 +++++-- .../javadoc/JavadocAllClassesTemplateMapTest.kt | 49 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 plugins/javadoc/src/test/kotlin/javadoc/JavadocAllClassesTemplateMapTest.kt (limited to 'plugins/javadoc') 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().templateMap + assertEquals("main", map["kind"]) + assertEquals("All Classes", map["title"]) + + val list = assertIsInstance>(map["list"]) + assertEquals(2, list.size, "Expected two classes") + + val classA = assertIsInstance(list[0]) + assertEquals("ClassA", classA.name) + assertEquals(DRI("package0", "ClassA"), classA.dri.single()) + assertEquals(ContentKind.Classlikes, classA.kind) + + val classB = assertIsInstance(list[1]) + assertEquals("ClassB", classB.name) + assertEquals(DRI("package1", "ClassB"), classB.dri.single()) + assertEquals(ContentKind.Classlikes, classB.kind) + } + } +} -- cgit