Waterfall/BungeeCord-Patches/0013-Better-unit-tests-for-Chat-API.patch
Shane Freeder ba94135bd5
Updated Upstream (BungeeCord)
Upstream has released updates that appears 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:
fe2a39e4 Minecraft 1.14.3-pre4 support
8eb56837 Bundle 1.14.2 translations
2019-06-24 18:42:23 +01:00

58 lines
2.6 KiB
Diff

From 719e279e25eeee7776bc671b039cf71cc4ed5674 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 64db54af..51ac3deb 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
@@ -226,6 +226,26 @@ public class ComponentsTest
Assert.assertEquals( eventRetention[1].getClickEvent(), testClickEvent );
}
+ @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();
+
+ Assert.assertTrue( components[0].isBold() );
+ Assert.assertTrue( components[0].isUnderlined() );
+ Assert.assertTrue( components[0].isItalic() );
+ Assert.assertTrue( components[0].isStrikethrough() );
+ Assert.assertTrue( components[0].isObfuscated() );
+
+ Assert.assertTrue( components[1].isBold() );
+ Assert.assertFalse( components[1].isUnderlined() );
+ Assert.assertTrue( components[1].isItalic() );
+ Assert.assertFalse( components[1].isStrikethrough() );
+ Assert.assertTrue( components[1].isObfuscated() );
+ }
+
@Test(expected = IllegalArgumentException.class)
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 7e63488c..e85c55b7 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
@@ -13,4 +13,12 @@ public class TranslatableComponentTest
Assert.assertEquals( "Test string with 2 placeholders: aoeu", testComponent.toPlainText() );
Assert.assertEquals( "§fTest string with §f2§f placeholders: §faoeu", testComponent.toLegacyText() );
}
+
+ @Test
+ public void testEscapedPercentInPlainText()
+ {
+ TranslatableComponent testComponent = new TranslatableComponent( "Test string with %% sign" );
+ Assert.assertEquals( "Test string with % sign", testComponent.toPlainText() );
+ Assert.assertEquals( "§fTest string with §f%§f sign", testComponent.toLegacyText() );
+ }
}
--
2.22.0