2021-10-09 11:43:12 +02:00
|
|
|
From 1ea8b846f0c0dab4d0a9d526e8bf7052fc3b8bdc Mon Sep 17 00:00:00 2001
|
2016-05-28 18:34:39 +02:00
|
|
|
From: Tux <write@imaginarycode.com>
|
|
|
|
Date: Thu, 19 May 2016 17:36:31 -0600
|
|
|
|
Subject: [PATCH] Better unit tests for Chat API
|
|
|
|
|
|
|
|
|
2018-01-28 12:36:01 +01:00
|
|
|
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
|
2021-10-09 11:43:12 +02:00
|
|
|
index 20c62f1d..e8d65a54 100644
|
2018-01-28 12:36:01 +01:00
|
|
|
--- 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
|
2020-07-19 15:26:04 +02:00
|
|
|
@@ -450,6 +450,26 @@ public class ComponentsTest
|
2016-05-28 18:34:39 +02:00
|
|
|
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()
|
|
|
|
{
|
2018-01-28 12:36:01 +01:00
|
|
|
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
|
2020-01-15 01:04:50 +01:00
|
|
|
index 9e37eed0..a25a01b8 100644
|
2018-01-28 12:36:01 +01:00
|
|
|
--- 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
|
2020-01-15 01:04:50 +01:00
|
|
|
@@ -25,4 +25,12 @@ public class TranslatableComponentTest
|
|
|
|
Assert.assertEquals( "Test string with a placeholder", TextComponent.toPlainText( baseComponents ) );
|
|
|
|
Assert.assertEquals( "§fTest string with §fa§f placeholder", TextComponent.toLegacyText( baseComponents ) );
|
2018-01-28 12:36:01 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testEscapedPercentInPlainText()
|
|
|
|
+ {
|
|
|
|
+ TranslatableComponent testComponent = new TranslatableComponent( "Test string with %% sign" );
|
2019-04-23 10:09:26 +02:00
|
|
|
+ Assert.assertEquals( "Test string with % sign", testComponent.toPlainText() );
|
|
|
|
+ Assert.assertEquals( "§fTest string with §f%§f sign", testComponent.toLegacyText() );
|
2018-01-28 12:36:01 +01:00
|
|
|
+ }
|
|
|
|
}
|
2016-05-28 18:34:39 +02:00
|
|
|
--
|
2021-10-09 11:43:12 +02:00
|
|
|
2.30.1 (Apple Git-130)
|
2016-05-28 18:34:39 +02:00
|
|
|
|