Adds some tests for the color helper
All checks were successful
EpicKnarvik97/KnarLib/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2023-01-25 16:04:39 +01:00
parent 341fce44e5
commit f1ccee13c2

View File

@ -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));
}
}