Allow appending BaseComponent arrays in ComponentBuilder

This commit is contained in:
Mystiflow
2017-08-11 14:28:18 +01:00
committed by md_5
parent a1f9c2e7d4
commit fd675022c0
2 changed files with 74 additions and 5 deletions

View File

@@ -13,6 +13,23 @@ import org.junit.Test;
public class ComponentsTest
{
@Test
public void testBuilderAppend()
{
ClickEvent clickEvent = new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/help " );
HoverEvent hoverEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Hello world" ).create() );
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
builder.append( new ComponentBuilder( "world!" ).color( ChatColor.GREEN ).event( hoverEvent ).event( clickEvent ).create() );
BaseComponent[] components = builder.create();
Assert.assertEquals( components[1].getHoverEvent(), hoverEvent );
Assert.assertEquals( components[1].getClickEvent(), clickEvent );
Assert.assertEquals( "Hello world!", BaseComponent.toPlainText( components ) );
Assert.assertEquals( ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!", BaseComponent.toLegacyText( components ) );
}
@Test
public void testBasicComponent()
{