1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-12-01 20:05:43 +00:00

Actualized work with pre type of text - now it is possible to use language for formatting of text

This commit is contained in:
2020-01-03 00:27:24 +06:00
parent dbef69ffac
commit 398adf06ff
3 changed files with 62 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils
import kotlin.test.Test
import kotlin.test.assertEquals
class StringFormattingTests {
@Test
fun testThatPreEscapingWorksCorrectly() {
val originalHelloWorld = """
fun main() {
println("Hello world")
}
""".replace(" ", "")
val helloWorldLanguage = "kotlin"
assertEquals(
"<pre><code class=\"language-$helloWorldLanguage\">$originalHelloWorld</code></pre>",
originalHelloWorld.preHTML(
helloWorldLanguage
)
)
assertEquals(
"<pre>$originalHelloWorld</pre>",
originalHelloWorld.preHTML()
)
assertEquals(
"```$helloWorldLanguage\n$originalHelloWorld\n```",
originalHelloWorld.preMarkdown(
helloWorldLanguage
)
)
assertEquals(
"```\n$originalHelloWorld\n```",
originalHelloWorld.preMarkdown()
)
}
}