diff options
-rw-r--r-- | core/src/test/kotlin/format/PackageDocsTest.kt | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/core/src/test/kotlin/format/PackageDocsTest.kt b/core/src/test/kotlin/format/PackageDocsTest.kt index 704f7b99..b7fff1e2 100644 --- a/core/src/test/kotlin/format/PackageDocsTest.kt +++ b/core/src/test/kotlin/format/PackageDocsTest.kt @@ -1,19 +1,46 @@ package org.jetbrains.dokka.tests.format +import com.intellij.openapi.Disposable +import com.intellij.openapi.util.Disposer import com.nhaarman.mockito_kotlin.any import com.nhaarman.mockito_kotlin.doAnswer import com.nhaarman.mockito_kotlin.eq import com.nhaarman.mockito_kotlin.mock import org.jetbrains.dokka.* import org.jetbrains.dokka.tests.assertEqualsIgnoringSeparators +import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment +import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor +import org.junit.After import org.junit.Assert.assertEquals +import org.junit.Before import org.junit.Test import java.io.File class PackageDocsTest { + + private lateinit var testDisposable: Disposable + + @Before + fun setup() { + testDisposable = Disposer.newDisposable() + } + + @After + fun cleanup() { + Disposer.dispose(testDisposable) + } + + fun createPackageDocs(linkResolver: DeclarationLinkResolver?): PackageDocs { + val environment = KotlinCoreEnvironment.createForTests(testDisposable, CompilerConfiguration.EMPTY, EnvironmentConfigFiles.JVM_CONFIG_FILES) + return PackageDocs(linkResolver, DokkaConsoleLogger, environment, mock(), mock()) + } + @Test fun verifyParse() { - val docs = PackageDocs(null, DokkaConsoleLogger) + + val docs = createPackageDocs(null) docs.parse("testdata/packagedocs/stdlib.md", emptyList()) val packageContent = docs.packageContent["kotlin"]!! val block = (packageContent.children.single() as ContentBlock).children.first() as ContentText @@ -28,7 +55,7 @@ class PackageDocsTest { val mockPackageDescriptor = mock<PackageFragmentDescriptor> {} - val docs = PackageDocs(mockLinkResolver, DokkaConsoleLogger) + val docs = createPackageDocs(mockLinkResolver) docs.parse("testdata/packagedocs/referenceLinks.md", listOf(mockPackageDescriptor)) checkMarkdownOutput(docs, "testdata/packagedocs/referenceLinks") |