Waterfall/BungeeCord-Patches/0012-Better-unit-tests-for-Chat-API.patch
Shane Freeder 6db0f23791
Updated Upstream (BungeeCord)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

BungeeCord Changes:
52ab21b1 #3682: Bump io.netty:netty-bom from 4.1.109.Final to 4.1.110.Final
8e8a6353 Minecraft 24w21b support
18eae8a1 #3664: Improve chat test code quality
2024-05-27 16:20:46 +01:00

57 lines
2.4 KiB
Diff

From 8f8e0123c0deaad1471e4681e747ad93045b9798 Mon Sep 17 00:00:00 2001
From: Tux <write@imaginarycode.com>
Date: Thu, 19 May 2016 17:36:31 -0600
Subject: [PATCH] Better unit tests for Chat API
diff --git a/chat/src/test/java/net/md_5/bungee/api/chat/ComponentsTest.java b/chat/src/test/java/net/md_5/bungee/api/chat/ComponentsTest.java
index 2d8233e6..276322a8 100644
--- a/chat/src/test/java/net/md_5/bungee/api/chat/ComponentsTest.java
+++ b/chat/src/test/java/net/md_5/bungee/api/chat/ComponentsTest.java
@@ -673,6 +673,26 @@ public class ComponentsTest
assertEquals( testClickEvent, extraGetter.apply( eventRetention, 1 ).getClickEvent() );
}
+ @Test
+ public void testBuilderSpecialFormatting()
+ {
+ BaseComponent[] components = new ComponentBuilder( "Hello " )
+ .bold(true).underlined(true).italic(true).strikethrough(true).obfuscated(true)
+ .append("World").underlined(false).strikethrough(false).create();
+
+ assertTrue( components[0].isBold() );
+ assertTrue( components[0].isUnderlined() );
+ assertTrue( components[0].isItalic() );
+ assertTrue( components[0].isStrikethrough() );
+ assertTrue( components[0].isObfuscated() );
+
+ assertTrue( components[1].isBold() );
+ assertFalse( components[1].isUnderlined() );
+ assertTrue( components[1].isItalic() );
+ assertFalse( components[1].isStrikethrough() );
+ assertTrue( components[1].isObfuscated() );
+ }
+
@Test
public void testLoopSimple()
{
diff --git a/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java b/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java
index 995c70f2..dd9f040d 100644
--- a/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java
+++ b/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java
@@ -48,4 +48,11 @@ public class TranslatableComponentTest
assertEquals( "Buried Treasure Map", one_four_two.toPlainText() );
}
+ @Test
+ public void testEscapedPercentInPlainText()
+ {
+ TranslatableComponent testComponent = new TranslatableComponent( "Test string with %% sign" );
+ assertEquals( "Test string with % sign", testComponent.toPlainText() );
+ assertEquals( "§fTest string with §f%§f sign", testComponent.toLegacyText() );
+ }
}
--
2.45.1