aboutsummaryrefslogtreecommitdiff
path: root/src/test/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/kotlin')
-rw-r--r--src/test/kotlin/testutil/ItemResources.kt7
-rw-r--r--src/test/kotlin/util/TextUtilText.kt15
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/kotlin/testutil/ItemResources.kt b/src/test/kotlin/testutil/ItemResources.kt
index bd3c438..ee2a322 100644
--- a/src/test/kotlin/testutil/ItemResources.kt
+++ b/src/test/kotlin/testutil/ItemResources.kt
@@ -4,6 +4,8 @@ import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtOps
import net.minecraft.nbt.StringNbtReader
+import net.minecraft.text.Text
+import net.minecraft.text.TextCodecs
import moe.nea.firmament.test.FirmTestBootstrap
object ItemResources {
@@ -22,6 +24,11 @@ object ItemResources {
return StringNbtReader.parse(loadString(path))
}
+ fun loadText(name: String): Text {
+ return TextCodecs.CODEC.parse(NbtOps.INSTANCE, loadSNbt("testdata/chat/$name.snbt"))
+ .getOrThrow { IllegalStateException("Could not load test chat '$name': $it") }
+ }
+
fun loadItem(name: String): ItemStack {
// TODO: make the load work with enchantments
return ItemStack.CODEC.parse(NbtOps.INSTANCE, loadSNbt("testdata/items/$name.snbt"))
diff --git a/src/test/kotlin/util/TextUtilText.kt b/src/test/kotlin/util/TextUtilText.kt
new file mode 100644
index 0000000..7091f4e
--- /dev/null
+++ b/src/test/kotlin/util/TextUtilText.kt
@@ -0,0 +1,15 @@
+package moe.nea.firmament.test.util
+
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Test
+import moe.nea.firmament.test.testutil.ItemResources
+import moe.nea.firmament.util.getLegacyFormatString
+
+class TextUtilText {
+ @Test
+ fun testThing() {
+ // TODO: add more tests that are directly validated with 1.8.9 code
+ val text = ItemResources.loadText("all-chat")
+ Assertions.assertEquals("§r§r§8[§r§9302§r§8] §r§6♫ §r§b[MVP§r§d+§r§b] lrg89§r§f: test§r", text.getLegacyFormatString())
+ }
+}