From 1aa1a1328f91f6cab39a958396a7eb854ad2ca13 Mon Sep 17 00:00:00 2001 From: olim Date: Sun, 18 Feb 2024 11:48:58 +0000 Subject: add text style to the replacement text make it so styles can be added to the replacement text --- .../skyblock/chat/ChatRulesHandlerTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandlerTest.java (limited to 'src/test/java/de/hysky/skyblocker') diff --git a/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandlerTest.java b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandlerTest.java new file mode 100644 index 00000000..2c1b7956 --- /dev/null +++ b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandlerTest.java @@ -0,0 +1,35 @@ +package de.hysky.skyblocker.skyblock.chat; + +import net.minecraft.text.MutableText; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.awt.*; + +import static org.junit.jupiter.api.Assertions.*; + +class ChatRulesHandlerTest { + + @Test + void formatText() { + //generate test text + MutableText testText = Text.empty(); + Style style = Style.EMPTY.withFormatting(Formatting.DARK_BLUE); + Text.of("test").getWithStyle(style).forEach(testText::append); + style = style.withFormatting(Formatting.UNDERLINE); + Text.of("line").getWithStyle(style).forEach(testText::append); + style = style.withFormatting(Formatting.DARK_GREEN); + Text.of("dark green").getWithStyle(style).forEach(testText::append); + style = style.withFormatting(Formatting.ITALIC); + Text.of("italic").getWithStyle(style).forEach(testText::append); + + //generated text + MutableText text = ChatRulesHandler.formatText("&1test&nline&2dark green&oitalic"); + + Assertions.assertEquals(text,testText); + + } +} \ No newline at end of file -- cgit