-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(minimessage): tests for progress and repeat tags
- Loading branch information
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...sage/src/test/java/net/kyori/adventure/text/minimessage/tag/standard/ProgressTagTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package net.kyori.adventure.text.minimessage.tag.standard; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.TextComponent; | ||
import net.kyori.adventure.text.minimessage.AbstractTest; | ||
import net.kyori.adventure.text.minimessage.tag.resolver.Formatter; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import static net.kyori.adventure.text.Component.empty; | ||
import static net.kyori.adventure.text.Component.text; | ||
import static net.kyori.adventure.text.format.NamedTextColor.BLUE; | ||
import static net.kyori.adventure.text.format.NamedTextColor.GREEN; | ||
import static net.kyori.adventure.text.format.TextColor.color; | ||
|
||
public class ProgressTagTest extends AbstractTest { | ||
|
||
@Test | ||
void testConstantProgress() { | ||
final String input = "<progress:0.5:|:10:green:#696969>"; | ||
final Component filled = text("|", GREEN); | ||
final Component empty = text("|", color(0x696969)); | ||
final Component expected = empty() | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(empty) | ||
.append(empty) | ||
.append(empty) | ||
.append(empty) | ||
.append(empty); | ||
assertParsedEquals(expected, input); | ||
} | ||
|
||
@Test | ||
void testSupplierProgress() { | ||
final Supplier<Double> progressSupplier = () -> 0.777; | ||
final String input = "<why_am_i_doing_this:|:12:blue:#FF5555>"; | ||
final Component filled = text("|", BLUE); | ||
final Component empty = text("|", color(0xFF5555)); | ||
final Component expected = empty() | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(filled) | ||
.append(empty) | ||
.append(empty) | ||
.append(empty); | ||
assertParsedEquals(expected, input, Formatter.progress("why_am_i_doing_this", progressSupplier)); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...essage/src/test/java/net/kyori/adventure/text/minimessage/tag/standard/RepeatTagTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package net.kyori.adventure.text.minimessage.tag.standard; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.AbstractTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static net.kyori.adventure.text.Component.*; | ||
import static net.kyori.adventure.text.event.ClickEvent.runCommand; | ||
import static net.kyori.adventure.text.event.HoverEvent.showText; | ||
import static net.kyori.adventure.text.format.NamedTextColor.GREEN; | ||
import static net.kyori.adventure.text.format.NamedTextColor.RED; | ||
import static net.kyori.adventure.text.format.Style.style; | ||
import static net.kyori.adventure.text.format.TextDecoration.BOLD; | ||
import static net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.parsed; | ||
|
||
public class RepeatTagTest extends AbstractTest { | ||
|
||
@Test | ||
void testSimpleRepeat() { | ||
final String input = "<repeat:5:'Hello World!'>"; | ||
final Component expected = empty() | ||
.append(text("Hello World!")) | ||
.append(text("Hello World!")) | ||
.append(text("Hello World!")) | ||
.append(text("Hello World!")) | ||
.append(text("Hello World!")); | ||
assertParsedEquals(expected, input); | ||
} | ||
|
||
@Test | ||
void spaceRepeat() { | ||
final String input = "<repeat:5:' '>"; | ||
Component expected = empty() | ||
.append(text(" ")) | ||
.append(text(" ")) | ||
.append(text(" ")) | ||
.append(text(" ")) | ||
.append(text(" ")); | ||
assertParsedEquals(expected, input); | ||
} | ||
|
||
@Test | ||
void fancyRepeat() { | ||
final String input = "A<idk_what_to_name><repeat:12:'<red>Mini</red><green>Message</green><newline><click:run_command:'/hello world'><hover:show_text:'AAA'>Test</hover></click>'>"; | ||
final Component toRepeat = empty() | ||
.append(text("Mini", RED)) | ||
.append(text("Message", GREEN)) | ||
.append(newline()) | ||
.append(text("Test").clickEvent(runCommand("/hello world")).hoverEvent(showText(text("AAA")))); | ||
final Component expected = empty().append(text("A")).append( | ||
text("cool placeholder value", style(BOLD)) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
.append(toRepeat) | ||
); | ||
assertParsedEquals(expected, input, parsed("idk_what_to_name", "<bold>cool placeholder value")); | ||
} | ||
|
||
} |