1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-03 00:15:27 +00:00
tgbotapi/tgbotapi.core/src/commonTest/kotlin/dev/inmo/tgbotapi/types/MessageEntity/EntitiesTestText.kt

63 lines
1.7 KiB
Kotlin
Raw Normal View History

2020-11-06 12:52:59 +00:00
package dev.inmo.tgbotapi.types.MessageEntity
import dev.inmo.tgbotapi.types.MessageEntity.textsources.*
import kotlin.test.assertTrue
const val testText = "It (is?) is simple hello world with #tag and @mention"
const val formattedV2Text = "It \\(is?\\) *_is_ ~__simple__~* ||hello world|| with \\#tag and @mention"
const val formattedHtmlText = "It (is?) <b><i>is</i> <s><u>simple</u></s></b> <span class=\"tg-spoiler\">hello world</span> with #tag and @mention"
2020-11-06 12:52:59 +00:00
internal val testTextEntities = listOf(
RawMessageEntity(
"bold",
9,
2020-11-06 12:52:59 +00:00
9
),
RawMessageEntity(
"italic",
9,
2020-11-06 12:52:59 +00:00
2
),
RawMessageEntity(
"strikethrough",
12,
2020-11-06 12:52:59 +00:00
6
),
RawMessageEntity(
"underline",
12,
2020-11-06 12:52:59 +00:00
6
),
2021-12-31 07:48:51 +00:00
RawMessageEntity(
"spoiler",
19,
2021-12-31 07:48:51 +00:00
11
),
2020-11-06 12:52:59 +00:00
RawMessageEntity(
"hashtag",
36,
2020-11-06 12:52:59 +00:00
4
),
RawMessageEntity(
"mention",
45,
2021-04-28 13:54:57 +00:00
8
2020-11-06 12:52:59 +00:00
)
)
2021-05-29 09:34:14 +00:00
fun TextSourcesList.testTextSources() {
2021-04-28 13:54:57 +00:00
assertTrue (first() is RegularTextSource)
assertTrue (get(1) is BoldTextSource)
assertTrue (get(2) is RegularTextSource)
2021-12-31 07:48:51 +00:00
assertTrue (get(3) is SpoilerTextSource)
2021-04-28 13:54:57 +00:00
assertTrue (get(4) is RegularTextSource)
2021-12-31 07:48:51 +00:00
assertTrue (get(5) is HashTagTextSource)
assertTrue (get(6) is RegularTextSource)
assertTrue (get(7) is MentionTextSource)
2020-11-06 12:52:59 +00:00
2021-04-28 13:54:57 +00:00
val boldSource = get(1) as BoldTextSource
assertTrue (boldSource.subsources.first() is ItalicTextSource)
assertTrue (boldSource.subsources[1] is RegularTextSource)
assertTrue (boldSource.subsources[2] is StrikethroughTextSource)
assertTrue ((boldSource.subsources[2] as StrikethroughTextSource).subsources.first() is UnderlineTextSource)
2020-11-06 12:52:59 +00:00
}