Skip to content

Commit

Permalink
Update tests with code show/hide line numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Jul 22, 2024
1 parent 585fd7f commit 1db75c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,11 @@ class HtmlNodeRendererTest {
fun code() {
val out = readParts("block/code.html")

assertEquals(out.next(), Code("Code", language = null).render())
assertEquals(out.next(), Code("class Point {\n ...\n}", language = null).render())
assertEquals(out.next(), Code("class Point {\n ...\n}", language = "java").render())
assertEquals(out.next(), Code("<a href=\"#\">", language = "html").render())
assertEquals(out.next(), Code("Code", language = null, showLineNumbers = true).render())
assertEquals(out.next(), Code("Code", language = null, showLineNumbers = false).render())
assertEquals(out.next(), Code("class Point {\n ...\n}", language = null, showLineNumbers = true).render())
assertEquals(out.next(), Code("class Point {\n ...\n}", language = "java", showLineNumbers = false).render())
assertEquals(out.next(), Code("<a href=\"#\">", language = "html", showLineNumbers = true).render())
}

@Test
Expand Down
10 changes: 9 additions & 1 deletion core/src/test/resources/rendering/block/code.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

---

<pre>
<code class="nohljsln">
Code
</code>
</pre>

---

<pre>
<code>
class Point {
Expand All @@ -17,7 +25,7 @@
---

<pre>
<code class="language-java">
<code class="language-java nohljsln">
class Point {
...
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import eu.iamgio.quarkdown.context.MutableContext
import eu.iamgio.quarkdown.flavor.quarkdown.QuarkdownFlavor
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertIs

/**
Expand All @@ -18,7 +19,8 @@ class TextTest {
val code =
code(
MutableContext(QuarkdownFlavor),
"kotlin",
language = "kotlin",
showLineNumbers = false,
MarkdownContent(listOf(Text("fun foo() = 1"))),
)

Expand All @@ -27,5 +29,6 @@ class TextTest {
assertIs<Code>(node)
assertEquals("fun foo() = 1", node.content)
assertEquals("kotlin", node.language)
assertFalse(node.showLineNumbers)
}
}

0 comments on commit 1db75c6

Please sign in to comment.