From 2eb805e47505388c0e47102e9257f6f79681e699 Mon Sep 17 00:00:00 2001
From: Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com>
Date: Thu, 9 Mar 2017 17:47:09 +0300
Subject: Create HTML based format for kotlin-website

---
 .../kotlin/format/KotlinWebSiteHtmlFormatTest.kt   | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt

(limited to 'core/src/test')

diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
new file mode 100644
index 00000000..5c2fbe75
--- /dev/null
+++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
@@ -0,0 +1,74 @@
+package org.jetbrains.dokka.tests
+
+import org.jetbrains.dokka.*
+import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
+import org.junit.Test
+
+class KotlinWebSiteHtmlFormatTest {
+    private val kwsService = KotlinWebsiteHtmlFormatService(InMemoryLocationService, KotlinLanguageService(), listOf())
+
+
+    @Test fun dropImport() {
+        verifyKWSNodeByName("dropImport", "foo")
+    }
+
+    @Test fun sample() {
+        verifyKWSNodeByName("sample", "foo")
+    }
+
+    @Test fun sampleWithAsserts() {
+        verifyKWSNodeByName("sampleWithAsserts", "a")
+    }
+
+    @Test fun newLinesInSamples() {
+        verifyKWSNodeByName("newLinesInSamples", "foo")
+    }
+
+    @Test fun newLinesInImportList() {
+        verifyKWSNodeByName("newLinesInImportList", "foo")
+    }
+
+    @Test fun returnTag() {
+        verifyKWSNodeByName("returnTag", "indexOf")
+    }
+
+    @Test fun overloadGroup() {
+        verifyKWSNodeByName("overloadGroup", "magic")
+    }
+
+    @Test fun dataTags() {
+        val module = buildMultiplePlatforms("dataTags")
+        verifyMultiplatformPackage(module, "dataTags")
+    }
+
+    @Test fun dataTagsInGroupNode() {
+        val path = "dataTagsInGroupNode"
+        val module = buildMultiplePlatforms(path)
+        verifyModelOutput(module, ".html", "testdata/format/website-html/$path/multiplatform.kt") { model, output ->
+            kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.find { it.kind == NodeKind.GroupNode }.singletonOrEmptyList())
+        }
+        verifyMultiplatformPackage(module, path)
+    }
+
+    private fun verifyKWSNodeByName(fileName: String, name: String) {
+        verifyOutput("testdata/format/website-html/$fileName.kt", ".html", format = "kotlin-website-html") { model, output ->
+            kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name })
+        }
+    }
+
+    private fun buildMultiplePlatforms(path: String): DocumentationModule {
+        val module = DocumentationModule("test")
+        val options = DocumentationOptions("", "html", generateIndexPages = false)
+        appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), options = options)
+        appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/jre7.kt"), defaultPlatforms = listOf("JVM", "JRE7"), options = options)
+        appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/js.kt"), defaultPlatforms = listOf("JS"), options = options)
+        return module
+    }
+
+    private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) {
+        verifyModelOutput(module, ".package.html", "testdata/format/website-html/$path/multiplatform.kt") { model, output ->
+            kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members)
+        }
+    }
+
+}
-- 
cgit