aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-03-18 19:21:08 +0100
committerPaweł Marks <pmarks@virtuslab.com>2020-03-18 19:21:08 +0100
commit4c8f3bcba59f06a9e8eabe6ac7da8ca976504092 (patch)
treea68c0bf1217010d42bf71d021e1bb28af5620a8f
parent4e7af2084c98f905b4fcd7fbe231c19bf186205d (diff)
downloaddokka-4c8f3bcba59f06a9e8eabe6ac7da8ca976504092.tar.gz
dokka-4c8f3bcba59f06a9e8eabe6ac7da8ca976504092.tar.bz2
dokka-4c8f3bcba59f06a9e8eabe6ac7da8ca976504092.zip
Fix html renderer tests
-rw-r--r--plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt4
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt19
-rw-r--r--testApi/src/main/kotlin/testApi/context/MockContext.kt2
3 files changed, 15 insertions, 10 deletions
diff --git a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt
index 686baf04..f77ec086 100644
--- a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt
+++ b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt
@@ -1,6 +1,7 @@
package renderers
import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.renderers.html.RootCreator
import org.jetbrains.dokka.base.resolvers.DefaultLocationProviderFactory
import org.jetbrains.dokka.base.resolvers.LocationProvider
import org.jetbrains.dokka.base.resolvers.LocationProviderFactory
@@ -24,7 +25,8 @@ abstract class RenderingOnlyTestBase {
val files = TestOutputWriter()
val context = MockContext(
DokkaBase().outputWriter to { _ -> files },
- DokkaBase().locationProviderFactory to ::DefaultLocationProviderFactory
+ DokkaBase().locationProviderFactory to ::DefaultLocationProviderFactory,
+ DokkaBase().htmlPreprocessors to { _ -> RootCreator }
)
protected val renderedContent: Element by lazy {
diff --git a/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt
index f1d50007..f46f8b59 100644
--- a/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/PlatformDependentHintTest.kt
@@ -5,8 +5,10 @@ import org.jetbrains.dokka.base.renderers.html.HtmlRenderer
import org.jetbrains.dokka.pages.PlatformData
import org.jetbrains.dokka.pages.TextStyle
import org.junit.jupiter.api.Test
+import renderers.Div
import renderers.RenderingOnlyTestBase
import renderers.TestPage
+import renderers.match
class PlatformDependentHintTest : RenderingOnlyTestBase() {
private val pl1 = PlatformData("pl1", Platform.js, listOf("pl1"))
@@ -24,7 +26,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() {
}
HtmlRenderer(context).render(page)
- assert(linesAfterContentTag().contains("<div>abc</div></div>"))
+ renderedContent.match(Div("abc"))
}
@Test
@@ -38,7 +40,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() {
}
HtmlRenderer(context).render(page)
- assert(linesAfterContentTag().contains("<div>a</div> [pl1]<div>b</div> [pl2]<div>c</div> [pl3]</div>"))
+ renderedContent.match(Div("a"), "[pl1]", Div("b"), "[pl2]", Div("c"), "[pl3]")
}
@Test
@@ -52,7 +54,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() {
}
HtmlRenderer(context).render(page)
- assert(linesAfterContentTag().contains("<div>ab</div> [pl1]<div>bc</div> [pl2]</div>"))
+ renderedContent.match(Div("ab"), "[pl1]", Div("bc"), "[pl2]")
}
@Test
@@ -66,7 +68,7 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() {
}
HtmlRenderer(context).render(page)
- assert(linesAfterContentTag().contains("<div>ab</div></div>"))
+ renderedContent.match(Div("ab"))
}
@Test
@@ -82,13 +84,13 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() {
}
HtmlRenderer(context).render(page)
- assert(linesAfterContentTag().contains("<div><div>ab</div></div> [pl1]<div><div>a</div>b</div> [pl2]</div>"))
+ renderedContent.match(Div(Div("ab")), "[pl1]", Div(Div("a"), "b"), "[pl2]")
}
@Test
fun caseWithGroupNotBreakingSimplification() {
val page = TestPage {
- platformDependentHint(platformData = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) {
+ platformDependentHint(platformData = setOf(pl1, pl2)) {
group {
text("a", platformData = setOf(pl1, pl2))
text("b", platformData = setOf(pl1))
@@ -98,7 +100,8 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() {
}
HtmlRenderer(context).render(page)
- assert(linesAfterContentTag().contains("<div>ab</div></div>"))
+ println(renderedContent)
+ renderedContent.match("ab")
}
@Test
@@ -112,6 +115,6 @@ class PlatformDependentHintTest : RenderingOnlyTestBase() {
}
HtmlRenderer(context).render(page)
- assert(linesAfterContentTag().contains("<div>a</div> [pl1, pl2]<div>b</div> [pl3]</div>"))
+ renderedContent.match(Div("a"), "[pl1, pl2]", Div("b"), "[pl3]")
}
} \ No newline at end of file
diff --git a/testApi/src/main/kotlin/testApi/context/MockContext.kt b/testApi/src/main/kotlin/testApi/context/MockContext.kt
index d3def4dc..5236f1f4 100644
--- a/testApi/src/main/kotlin/testApi/context/MockContext.kt
+++ b/testApi/src/main/kotlin/testApi/context/MockContext.kt
@@ -30,7 +30,7 @@ class MockContext(
kclass.constructors.single { it.parameters.isEmpty() }.call().also { it.injectContext(this) }
} as T
- override fun <T : Any, E : ExtensionPoint<T>> get(point: E): List<T> = extensionMap[point] as List<T>
+ override fun <T : Any, E : ExtensionPoint<T>> get(point: E): List<T> = extensionMap[point].orEmpty() as List<T>
override fun <T : Any, E : ExtensionPoint<T>> single(point: E): T = get(point).single()