aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/model/PackagesTest.kt
diff options
context:
space:
mode:
authorSzymon Świstun <sswistun@virtuslab.com>2020-02-26 11:52:03 +0100
committerKamil Doległo <kamilok1965@interia.pl>2020-02-28 16:37:40 +0100
commitcacf1e0c6cda4e42fe6581946cad53a377c71ec7 (patch)
treec6bc41f74dde1962a0578597c5ddcc27fa356689 /plugins/base/src/test/kotlin/model/PackagesTest.kt
parent77d6ce22a286601bc5d1401619eb42fac58e7013 (diff)
downloaddokka-cacf1e0c6cda4e42fe6581946cad53a377c71ec7.tar.gz
dokka-cacf1e0c6cda4e42fe6581946cad53a377c71ec7.tar.bz2
dokka-cacf1e0c6cda4e42fe6581946cad53a377c71ec7.zip
Port some of the core tests from the previous model
Diffstat (limited to 'plugins/base/src/test/kotlin/model/PackagesTest.kt')
-rw-r--r--plugins/base/src/test/kotlin/model/PackagesTest.kt126
1 files changed, 126 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/model/PackagesTest.kt b/plugins/base/src/test/kotlin/model/PackagesTest.kt
new file mode 100644
index 00000000..e19cc82d
--- /dev/null
+++ b/plugins/base/src/test/kotlin/model/PackagesTest.kt
@@ -0,0 +1,126 @@
+package model
+
+import org.jetbrains.dokka.model.Package
+import org.junit.Test
+import utils.AbstractModelTest
+
+class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "packages") {
+
+ @Test
+ fun rootPackage() {
+ inlineModelTest(
+ """
+ |
+ """.trimIndent(),
+ prependPackage = false
+ ) {
+ with((this / "").cast<Package>()) {
+ name equals ""
+ children counts 0
+ }
+ }
+ }
+
+ @Test
+ fun simpleNamePackage() {
+ inlineModelTest(
+ """
+ |package simple
+ """.trimIndent(),
+ prependPackage = false
+ ) {
+ with((this / "simple").cast<Package>()) {
+ name equals "simple"
+ children counts 0
+ }
+ }
+ }
+
+ @Test
+ fun dottedNamePackage() {
+ inlineModelTest(
+ """
+ |package dot.name
+ """.trimIndent(),
+ prependPackage = false
+ ) {
+ with((this / "dot.name").cast<Package>()) {
+ name equals "dot.name"
+ children counts 0
+ }
+ }
+
+ }
+
+ @Test
+ fun multipleFiles() {
+ inlineModelTest(
+ """
+ |package dot.name
+ |/src/main/kotlin/packages/Test2.kt
+ |package simple
+ """.trimIndent(),
+ prependPackage = false
+ ) {
+ children counts 2
+ with((this / "dot.name").cast<Package>()) {
+ name equals "dot.name"
+ children counts 0
+ }
+ with((this / "simple").cast<Package>()) {
+ name equals "simple"
+ children counts 0
+ }
+ }
+ }
+
+ @Test
+ fun multipleFilesSamePackage() {
+ inlineModelTest(
+ """
+ |package simple
+ |/src/main/kotlin/packages/Test2.kt
+ |package simple
+ """.trimIndent(),
+ prependPackage = false
+ ) {
+ children counts 1
+ with((this / "simple").cast<Package>()) {
+ name equals "simple"
+ children counts 0
+ }
+ }
+ }
+
+ @Test
+ fun classAtPackageLevel() {
+ inlineModelTest(
+ """
+ |package simple.name
+ |
+ |class Foo {}
+ """.trimIndent(),
+ prependPackage = false
+ ) {
+ with((this / "simple.name").cast<Package>()) {
+ name equals "simple.name"
+ children counts 1
+ }
+ }
+ }
+
+ // todo
+// @Test fun suppressAtPackageLevel() {
+// verifyModel(
+// ModelConfig(
+// roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt", false)),
+// perPackageOptions = listOf(
+// PackageOptionsImpl(prefix = "simple.name", suppress = true)
+// ),
+// analysisPlatform = analysisPlatform
+// )
+// ) { model ->
+// assertEquals(0, model.members.count())
+// }
+// }
+} \ No newline at end of file