aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandlerTest.java
blob: 2c1b7956a2c75ff7fa82487af25434d566c0db97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);

    }
}