Skip to content

Commit

Permalink
Move translatable component test to the correct test class
Browse files Browse the repository at this point in the history
  • Loading branch information
Janmm14 committed Feb 27, 2024
1 parent 0f133ae commit 0d81143
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
25 changes: 0 additions & 25 deletions chat/src/test/java/net/md_5/bungee/api/chat/ComponentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,31 +560,6 @@ public void testLegacyConverter()
assertEquals( "http://google.com/test", url2.getValue() );
}

@Test
public void testTranslateComponent()
{
TranslatableComponent item = new TranslatableComponent( "item.swordGold.name" );
item.setColor( AQUA );
TranslatableComponent component = new TranslatableComponent( "commands.give.success", item, "5",
"thinkofdeath" );

assertEquals( "Given Golden Sword * 5 to thinkofdeath", component.toPlainText() );
assertEquals( "Given " + AQUA + "Golden Sword" + " * " + WHITE + "5 to " + WHITE + "thinkofdeath",
component.toLegacyText() );

BaseComponent legacyColorTest = new ComponentBuilder( "Test " ).color( RED ).append( component ).build();
assertEquals( RED + "Given " + AQUA + "Golden Sword" + RED + " * " + RED + "5 to " + RED + "thinkofdeath",
legacyColorTest.toLegacyText() );

TranslatableComponent positional = new TranslatableComponent( "book.pageIndicator", "5", "50" );

assertEquals( "Page 5 of 50", positional.toPlainText() );
assertEquals( "Page " + WHITE + "5 of " + WHITE + "50", positional.toLegacyText() );

TranslatableComponent one_four_two = new TranslatableComponent( "filled_map.buried_treasure" );
assertEquals( "Buried Treasure Map", one_four_two.toPlainText() );
}

@Test
public void testBuilderCreate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,29 @@ public void testJsonSerialisation()
assertEquals( "Test string with a placeholder", BaseComponent.toPlainText( parsed ) );
assertEquals( "Test string with " + WHITE + "a placeholder", BaseComponent.toLegacyText( parsed ) );
}

@Test
public void testTranslateComponent()
{
TranslatableComponent item = new TranslatableComponent( "item.swordGold.name" );
item.setColor( AQUA );
TranslatableComponent component = new TranslatableComponent( "commands.give.success", item, "5",
"thinkofdeath" );

assertEquals( "Given Golden Sword * 5 to thinkofdeath", component.toPlainText() );
assertEquals( "Given " + AQUA + "Golden Sword" + " * " + WHITE + "5 to " + WHITE + "thinkofdeath",
component.toLegacyText() );

BaseComponent legacyColorTest = new ComponentBuilder( "Test " ).color( RED ).append( component ).build();
assertEquals( RED + "Given " + AQUA + "Golden Sword" + RED + " * " + RED + "5 to " + RED + "thinkofdeath",
legacyColorTest.toLegacyText() );

TranslatableComponent positional = new TranslatableComponent( "book.pageIndicator", "5", "50" );

assertEquals( "Page 5 of 50", positional.toPlainText() );
assertEquals( "Page " + WHITE + "5 of " + WHITE + "50", positional.toLegacyText() );

TranslatableComponent one_four_two = new TranslatableComponent( "filled_map.buried_treasure" );
assertEquals( "Buried Treasure Map", one_four_two.toPlainText() );
}
}

0 comments on commit 0d81143

Please sign in to comment.