From 742be4ef7c024a5ea6023fb684cd24d1898f37e4 Mon Sep 17 00:00:00 2001 From: aleksZubakov Date: Thu, 12 Jul 2018 20:23:02 +0300 Subject: Test refactoring, add common platform tests --- core/src/test/kotlin/model/PackageTest.kt | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'core/src/test/kotlin/model/PackageTest.kt') diff --git a/core/src/test/kotlin/model/PackageTest.kt b/core/src/test/kotlin/model/PackageTest.kt index bc8a0e0d..80a2fd56 100644 --- a/core/src/test/kotlin/model/PackageTest.kt +++ b/core/src/test/kotlin/model/PackageTest.kt @@ -1,15 +1,14 @@ package org.jetbrains.dokka.tests -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.NodeKind -import org.jetbrains.dokka.PackageOptionsImpl +import org.jetbrains.dokka.* import org.jetbrains.kotlin.config.KotlinSourceRoot import org.junit.Assert.* import org.junit.Test -public class PackageTest { +abstract class BasePackageTest(val analysisPlatform: Platform) { + val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform) @Test fun rootPackage() { - checkSourceExistsAndVerifyModel("testdata/packages/rootPackage.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/packages/rootPackage.kt", defaultModelConfig) { model -> with(model.members.single()) { assertEquals(NodeKind.Package, kind) assertEquals("", name) @@ -22,7 +21,7 @@ public class PackageTest { } @Test fun simpleNamePackage() { - checkSourceExistsAndVerifyModel("testdata/packages/simpleNamePackage.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/packages/simpleNamePackage.kt", defaultModelConfig) { model -> with(model.members.single()) { assertEquals(NodeKind.Package, kind) assertEquals("simple", name) @@ -35,7 +34,7 @@ public class PackageTest { } @Test fun dottedNamePackage() { - checkSourceExistsAndVerifyModel("testdata/packages/dottedNamePackage.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/packages/dottedNamePackage.kt", defaultModelConfig) { model -> with(model.members.single()) { assertEquals(NodeKind.Package, kind) assertEquals("dot.name", name) @@ -53,7 +52,8 @@ public class PackageTest { roots = arrayOf( KotlinSourceRoot("testdata/packages/dottedNamePackage.kt"), KotlinSourceRoot("testdata/packages/simpleNamePackage.kt") - ) + ), + analysisPlatform = analysisPlatform ) ) { model -> assertEquals(2, model.members.count()) @@ -81,7 +81,8 @@ public class PackageTest { roots = arrayOf( KotlinSourceRoot("testdata/packages/simpleNamePackage.kt"), KotlinSourceRoot("testdata/packages/simpleNamePackage2.kt") - ) + ), + analysisPlatform = analysisPlatform ) ) { model -> assertEquals(1, model.members.count()) @@ -98,7 +99,10 @@ public class PackageTest { @Test fun classAtPackageLevel() { verifyModel( - ModelConfig(roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt"))) + ModelConfig( + roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt")), + analysisPlatform = analysisPlatform + ) ) { model -> assertEquals(1, model.members.count()) with(model.members.elementAt(0)) { @@ -118,7 +122,8 @@ public class PackageTest { roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt")), perPackageOptions = listOf( PackageOptionsImpl(prefix = "simple.name", suppress = true) - ) + ), + analysisPlatform = analysisPlatform ) ) { model -> assertEquals(1, model.members.count()) @@ -133,3 +138,7 @@ public class PackageTest { } } } + +class JSPackageTest : BasePackageTest(Platform.js) +class JVMPackageTest : BasePackageTest(Platform.jvm) +class CommonPackageTest : BasePackageTest(Platform.common) \ No newline at end of file -- cgit