aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-03 17:25:52 +0200
committerGitHub <noreply@github.com>2024-05-03 17:25:52 +0200
commit323cd55125f1485c71c49568aa919e5311c6263f (patch)
treec4c246921fad48623fb81b769ee78f5fa1873993 /src/test
parent5b2a2d067e68d500bd1c19088dae9e624eeae51f (diff)
downloadskyhanni-323cd55125f1485c71c49568aa919e5311c6263f.tar.gz
skyhanni-323cd55125f1485c71c49568aa919e5311c6263f.tar.bz2
skyhanni-323cd55125f1485c71c49568aa919e5311c6263f.zip
Add hover/click events back to custom chat messages (#1516)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/at/hannibal2/skyhanni/test/ComponentSpanTest.kt25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/test/java/at/hannibal2/skyhanni/test/ComponentSpanTest.kt b/src/test/java/at/hannibal2/skyhanni/test/ComponentSpanTest.kt
index 9b5f40829..7bef032c7 100644
--- a/src/test/java/at/hannibal2/skyhanni/test/ComponentSpanTest.kt
+++ b/src/test/java/at/hannibal2/skyhanni/test/ComponentSpanTest.kt
@@ -29,6 +29,19 @@ class ComponentSpanTest {
}
@Test
+ fun testRemovePrefix() {
+ val component = text("12345") {
+ appendSibling(text("12345"))
+ appendSibling(text("12345§r"))
+ }.intoSpan()
+ val prefixRemoved = component.removePrefix("123")
+ require(prefixRemoved.getText() == "451234512345§r")
+ require(component.stripHypixelMessage().getText() == "123451234512345")
+ require(component.stripHypixelMessage().slice().getText() == "123451234512345")
+ require(component.slice(0, 0).slice(0, 0).getText() == "")
+ }
+
+ @Test
fun testRegex() {
val component = text("12345") {
appendSibling(text("abcdef") {
@@ -37,16 +50,18 @@ class ComponentSpanTest {
appendSibling(text("12345"))
}
Pattern.compile("[0-9]*(?<middle>[a-z]+)[0-9]*").matchStyledMatcher(component) {
- require(group("middle")?.sampleStyleAtStart()?.color == EnumChatFormatting.RED)
+ require(groupOrThrow("middle")?.sampleStyleAtStart()?.color == EnumChatFormatting.RED)
}
val middlePartExtracted =
Pattern.compile("[0-9]*(?<middle>[0-9][a-z]+[0-9])[0-9]*").matchStyledMatcher(component) {
- require(group("middle")?.sampleComponents()?.size == 3)
- require(group("middle")?.sampleStyles()?.find { it.color != null }?.color == EnumChatFormatting.RED)
- group("middle")
+ require(groupOrThrow("middle")?.sampleComponents()?.size == 3)
+ require(
+ groupOrThrow("middle")?.sampleStyles()?.find { it.color != null }?.color == EnumChatFormatting.RED
+ )
+ groupOrThrow("middle")
}!!
Pattern.compile("(?<whole>c)").findStyledMatcher(middlePartExtracted) {
- require(group("whole")?.sampleStyleAtStart()?.color == EnumChatFormatting.RED)
+ require(groupOrThrow("whole")?.sampleStyleAtStart()?.color == EnumChatFormatting.RED)
}
}