2024-03-31 20:13:15 +02:00
|
|
|
From 455892a5aa7454f2c3e2fe8b8f6e6d0c6ad71c5d 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
|
2024-03-31 20:13:15 +02:00
|
|
|
index 7e14484b..3698762c 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
|
2024-03-31 20:13:15 +02:00
|
|
|
@@ -696,6 +696,26 @@ public class ComponentsTest
|
2023-09-24 01:22:13 +02:00
|
|
|
assertEquals( testClickEvent, extraGetter.apply( eventRetention, 1 ).getClickEvent() );
|
2016-05-28 18:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ @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();
|
|
|
|
+
|
2023-09-24 01:22:13 +02:00
|
|
|
+ assertTrue( components[0].isBold() );
|
|
|
|
+ assertTrue( components[0].isUnderlined() );
|
|
|
|
+ assertTrue( components[0].isItalic() );
|
|
|
|
+ assertTrue( components[0].isStrikethrough() );
|
|
|
|
+ assertTrue( components[0].isObfuscated() );
|
2016-05-28 18:34:39 +02:00
|
|
|
+
|
2023-09-24 01:22:13 +02:00
|
|
|
+ assertTrue( components[1].isBold() );
|
|
|
|
+ assertFalse( components[1].isUnderlined() );
|
|
|
|
+ assertTrue( components[1].isItalic() );
|
|
|
|
+ assertFalse( components[1].isStrikethrough() );
|
|
|
|
+ assertTrue( components[1].isObfuscated() );
|
2016-05-28 18:34:39 +02:00
|
|
|
+ }
|
|
|
|
+
|
2023-09-24 01:22:13 +02:00
|
|
|
@Test
|
2016-05-28 18:34:39 +02:00
|
|
|
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
|
2024-03-31 20:13:15 +02:00
|
|
|
index 47c06baa..2552a34f 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
|
2024-03-31 20:13:15 +02:00
|
|
|
assertEquals( "Test string with a placeholder", BaseComponent.toPlainText( baseComponents ) );
|
|
|
|
assertEquals( "§fTest string with §fa§f placeholder", BaseComponent.toLegacyText( baseComponents ) );
|
2018-01-28 12:36:01 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testEscapedPercentInPlainText()
|
|
|
|
+ {
|
|
|
|
+ TranslatableComponent testComponent = new TranslatableComponent( "Test string with %% sign" );
|
2023-09-24 01:22:13 +02:00
|
|
|
+ assertEquals( "Test string with % sign", testComponent.toPlainText() );
|
|
|
|
+ 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
|
|
|
--
|
2024-03-31 20:13:15 +02:00
|
|
|
2.44.0
|
2016-05-28 18:34:39 +02:00
|
|
|
|