diff --git a/src/test/java/net/knarcraft/knarlib/util/ColorHelperTest.java b/src/test/java/net/knarcraft/knarlib/util/ColorHelperTest.java new file mode 100644 index 0000000..05a2c10 --- /dev/null +++ b/src/test/java/net/knarcraft/knarlib/util/ColorHelperTest.java @@ -0,0 +1,41 @@ +package net.knarcraft.knarlib.util; + +import net.knarcraft.knarlib.property.ColorConversion; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ColorHelperTest { + + private final String rawHexColorMessage = "#ffdef3A colored message"; + private final String formattedHexColorMessage = "§x§f§f§d§e§f§3A colored message"; + + @Test + public void RGBColorAmpersandTest() { + ColorHelper.setRequireAmpersandInHexColors(false); + assertEquals(formattedHexColorMessage, + ColorHelper.translateColorCodes("&" + rawHexColorMessage, ColorConversion.RGB)); + } + + @Test + public void RGBColorNoAmpersandTest() { + ColorHelper.setRequireAmpersandInHexColors(false); + assertEquals(formattedHexColorMessage, + ColorHelper.translateColorCodes(rawHexColorMessage, ColorConversion.RGB)); + } + + @Test + public void RGBColorNoAmpersandAmpersandRequiredTest() { + ColorHelper.setRequireAmpersandInHexColors(true); + assertEquals(rawHexColorMessage, + ColorHelper.translateColorCodes(rawHexColorMessage, ColorConversion.RGB)); + } + + @Test + public void RGBColorAmpersandAmpersandRequiredTest() { + ColorHelper.setRequireAmpersandInHexColors(true); + assertEquals(formattedHexColorMessage, + ColorHelper.translateColorCodes("&" + rawHexColorMessage, ColorConversion.RGB)); + } + +}