aboutsummaryrefslogtreecommitdiff
path: root/plugins/gfm/src/test
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-09-03 10:24:44 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-07 08:07:10 +0200
commit495c64c64db5d7ebc44a7262e5bdeb7cc3a54f9c (patch)
tree41cad978990b52f84906e1effb87d472ce2c784c /plugins/gfm/src/test
parent581d064dc1fba01fd27f560e158df48498c7e776 (diff)
downloaddokka-495c64c64db5d7ebc44a7262e5bdeb7cc3a54f9c.tar.gz
dokka-495c64c64db5d7ebc44a7262e5bdeb7cc3a54f9c.tar.bz2
dokka-495c64c64db5d7ebc44a7262e5bdeb7cc3a54f9c.zip
Test images in GFM
Diffstat (limited to 'plugins/gfm/src/test')
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt24
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt8
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt34
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt16
4 files changed, 49 insertions, 33 deletions
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt
index ab1378d5..a205aa2f 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt
@@ -6,7 +6,7 @@ import org.jetbrains.dokka.gfm.CommonmarkRenderer
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.ContentDivergentGroup
import org.junit.jupiter.api.Test
-import renderers.TestPage
+import renderers.testPage
import testApi.testRunner.defaultSourceSet
import java.io.File
@@ -32,7 +32,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun simpleWrappingCase() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -48,7 +48,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun noPlatformHintCase() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test"), implicitlySourceSetHinted = false) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -64,7 +64,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentBetweenSourceSets() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -90,7 +90,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentInOneSourceSet() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(js)) {
divergent {
@@ -116,7 +116,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentInAndBetweenSourceSets() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
divergent {
@@ -152,7 +152,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentInAndBetweenSourceSetsWithGrouping() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
divergent {
@@ -200,7 +200,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentSameBefore() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
before {
@@ -227,7 +227,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentSameAfter() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
divergent {
@@ -254,7 +254,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentGroupedByBeforeAndAfter() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
before {
@@ -287,7 +287,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentDifferentBeforeAndAfter() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
before {
@@ -320,7 +320,7 @@ class DivergentTest : GfmRenderingOnlyTestBase() {
@Test
fun divergentInAndBetweenSourceSetsWithGroupingAncCommonParts() {
- val page = TestPage {
+ val page = testPage {
divergentGroup(ContentDivergentGroup.GroupID("test")) {
instance(setOf(DRI("test", "Test")), setOf(native)) {
divergent {
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt
index 42839282..53bee558 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt
@@ -9,7 +9,7 @@ class GroupWrappingTest : GfmRenderingOnlyTestBase() {
@Test
fun notWrapped() {
- val page = TestPage {
+ val page = testPage {
group {
text("a")
text("b")
@@ -24,7 +24,7 @@ class GroupWrappingTest : GfmRenderingOnlyTestBase() {
@Test
fun paragraphWrapped() {
- val page = TestPage {
+ val page = testPage {
group(styles = setOf(TextStyle.Paragraph)) {
text("a")
text("b")
@@ -39,7 +39,7 @@ class GroupWrappingTest : GfmRenderingOnlyTestBase() {
@Test
fun blockWrapped() {
- val page = TestPage {
+ val page = testPage {
group(styles = setOf(TextStyle.Block)) {
text("a")
text("b")
@@ -54,7 +54,7 @@ class GroupWrappingTest : GfmRenderingOnlyTestBase() {
@Test
fun nested() {
- val page = TestPage {
+ val page = testPage {
group(styles = setOf(TextStyle.Block)) {
text("a")
group(styles = setOf(TextStyle.Block)) {
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt
index 7464c079..9055fbc3 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt
@@ -2,15 +2,16 @@ package renderers.gfm
import org.jetbrains.dokka.gfm.CommonmarkRenderer
import org.junit.jupiter.api.Test
-import renderers.TestPage
-import org.jetbrains.dokka.base.translators.documentables.*
-import org.jetbrains.dokka.pages.TextStyle
+import renderers.testPage
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.pages.*
+import renderers.RawTestPage
class SimpleElementsTest : GfmRenderingOnlyTestBase() {
@Test
fun header() {
- val page = TestPage {
+ val page = testPage {
header(1, "The Hobbit or There and Back Again")
}
val expect = "//[testPage](test-page.md)\n\n\n\n# The Hobbit or There and Back Again \n"
@@ -20,7 +21,7 @@ class SimpleElementsTest : GfmRenderingOnlyTestBase() {
@Test
fun link() {
- val page = TestPage {
+ val page = testPage {
link("They are not all accounted for, the lost Seeing Stones.", "http://www.google.com")
}
val expect = "//[testPage](test-page.md)\n\n[They are not all accounted for, the lost Seeing Stones.](http://www.google.com)"
@@ -30,7 +31,7 @@ class SimpleElementsTest : GfmRenderingOnlyTestBase() {
@Test
fun bold() {
- val page = TestPage {
+ val page = testPage {
text("That there’s some good in this world, Mr. Frodo… and it’s worth fighting for.", styles = setOf(TextStyle.Bold))
}
val expect = "//[testPage](test-page.md)\n\n**That there’s some good in this world, Mr. Frodo… and it’s worth fighting for.**"
@@ -40,7 +41,7 @@ class SimpleElementsTest : GfmRenderingOnlyTestBase() {
@Test
fun italic() {
- val page = TestPage {
+ val page = testPage {
text("Even the smallest person can change the course of the future.", styles = setOf(TextStyle.Italic))
}
val expect = "//[testPage](test-page.md)\n\n*Even the smallest person can change the course of the future.*"
@@ -50,7 +51,7 @@ class SimpleElementsTest : GfmRenderingOnlyTestBase() {
@Test
fun italicAndBold() {
- val page = TestPage {
+ val page = testPage {
text("There is no curse in Elvish, Entish, or the tongues of Men for this treachery.", styles = setOf(TextStyle.Bold, TextStyle.Italic))
}
val expect = "//[testPage](test-page.md)\n\n***There is no curse in Elvish, Entish, or the tongues of Men for this treachery.***"
@@ -60,11 +61,26 @@ class SimpleElementsTest : GfmRenderingOnlyTestBase() {
@Test
fun strikethrough() {
- val page = TestPage {
+ val page = testPage {
text("A day may come when the courage of men fails… but it is not THIS day", styles = setOf(TextStyle.Strikethrough))
}
val expect = "//[testPage](test-page.md)\n\n~~A day may come when the courage of men fails… but it is not THIS day~~"
CommonmarkRenderer(context).render(page)
assert(renderedContent == expect)
}
+
+ @Test
+ fun images(){
+ val image = ContentEmbeddedResource(
+ children = emptyList(),
+ address = "https://www.google.pl/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
+ altText = "This is a google logo",
+ dci = DCI(setOf(DRI.topLevel), ContentKind.Main),
+ sourceSets = emptySet()
+ )
+ val page = RawTestPage(content = image)
+ val expect = "//[testPage](test-page.md)\n\n![This is a google logo](https://www.google.pl/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png)"
+ CommonmarkRenderer(context).render(page)
+ assert(renderedContent == expect)
+ }
} \ No newline at end of file
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt
index 999d7954..0d845a98 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt
@@ -5,7 +5,7 @@ import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.gfm.CommonmarkRenderer
import org.jetbrains.dokka.pages.TextStyle
import org.junit.jupiter.api.Test
-import renderers.TestPage
+import renderers.testPage
import testApi.testRunner.defaultSourceSet
import java.io.File
@@ -32,7 +32,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() {
@Test
fun platformIndependentCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) {
text("a")
text("b")
@@ -46,7 +46,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() {
@Test
fun completelyDivergentCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1))
text("b", sourceSets = setOf(pl2))
@@ -60,7 +60,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() {
@Test
fun overlappingCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1))
text("b", sourceSets = setOf(pl1, pl2))
@@ -74,7 +74,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() {
@Test
fun caseThatCanBeSimplified() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1, pl2))
text("b", sourceSets = setOf(pl1))
@@ -88,7 +88,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() {
@Test
fun caseWithGroupBreakingSimplification() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2), styles = setOf(TextStyle.Block)) {
group(styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1, pl2))
@@ -104,7 +104,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() {
@Test
fun caseWithGroupNotBreakingSimplification() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2)) {
group {
text("a", sourceSets = setOf(pl1, pl2))
@@ -120,7 +120,7 @@ class SourceSetDependentHintTest : GfmRenderingOnlyTestBase() {
@Test
fun partiallyUnifiedCase() {
- val page = TestPage {
+ val page = testPage {
sourceSetDependentHint(sourceSets = setOf(pl1, pl2, pl3), styles = setOf(TextStyle.Block)) {
text("a", sourceSets = setOf(pl1))
text("a", sourceSets = setOf(pl2))