aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/testutil/ItemResources.kt8
-rw-r--r--src/test/kotlin/util/TextUtilText.kt1
-rw-r--r--src/test/kotlin/util/skyblock/AbilityUtilsTest.kt1
-rw-r--r--src/test/kotlin/util/skyblock/ItemTypeTest.kt69
-rw-r--r--src/test/kotlin/util/skyblock/SackUtilTest.kt1
5 files changed, 27 insertions, 53 deletions
diff --git a/src/test/kotlin/testutil/ItemResources.kt b/src/test/kotlin/testutil/ItemResources.kt
index ee2a322..107b565 100644
--- a/src/test/kotlin/testutil/ItemResources.kt
+++ b/src/test/kotlin/testutil/ItemResources.kt
@@ -2,11 +2,14 @@ package moe.nea.firmament.test.testutil
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
+import net.minecraft.nbt.NbtElement
import net.minecraft.nbt.NbtOps
import net.minecraft.nbt.StringNbtReader
+import net.minecraft.registry.RegistryOps
import net.minecraft.text.Text
import net.minecraft.text.TextCodecs
import moe.nea.firmament.test.FirmTestBootstrap
+import moe.nea.firmament.util.MC
object ItemResources {
init {
@@ -23,15 +26,16 @@ object ItemResources {
fun loadSNbt(path: String): NbtCompound {
return StringNbtReader.parse(loadString(path))
}
+ fun getNbtOps(): RegistryOps<NbtElement> = MC.currentOrDefaultRegistries.getOps(NbtOps.INSTANCE)
fun loadText(name: String): Text {
- return TextCodecs.CODEC.parse(NbtOps.INSTANCE, loadSNbt("testdata/chat/$name.snbt"))
+ return TextCodecs.CODEC.parse(getNbtOps(), 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"))
+ return ItemStack.CODEC.parse(getNbtOps(), loadSNbt("testdata/items/$name.snbt"))
.getOrThrow { IllegalStateException("Could not load test item '$name': $it") }
}
}
diff --git a/src/test/kotlin/util/TextUtilText.kt b/src/test/kotlin/util/TextUtilText.kt
index e676d63..46ed3b4 100644
--- a/src/test/kotlin/util/TextUtilText.kt
+++ b/src/test/kotlin/util/TextUtilText.kt
@@ -2,7 +2,6 @@ package moe.nea.firmament.test.util
import io.kotest.core.spec.style.AnnotationSpec
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
diff --git a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt
index dbce762..206a357 100644
--- a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt
+++ b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt
@@ -2,7 +2,6 @@ package moe.nea.firmament.test.util.skyblock
import io.kotest.core.spec.style.AnnotationSpec
import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
import net.minecraft.text.Text
diff --git a/src/test/kotlin/util/skyblock/ItemTypeTest.kt b/src/test/kotlin/util/skyblock/ItemTypeTest.kt
index c89e57d..cca3d13 100644
--- a/src/test/kotlin/util/skyblock/ItemTypeTest.kt
+++ b/src/test/kotlin/util/skyblock/ItemTypeTest.kt
@@ -1,53 +1,26 @@
package moe.nea.firmament.test.util.skyblock
-import io.kotest.core.spec.style.AnnotationSpec
-import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
+import io.kotest.core.spec.style.ShouldSpec
+import io.kotest.matchers.shouldBe
import moe.nea.firmament.test.testutil.ItemResources
import moe.nea.firmament.util.skyblock.ItemType
-class ItemTypeTest : AnnotationSpec() {
- @Test
- fun testPetItem() {
- Assertions.assertEquals(
- ItemType.PET,
- ItemType.fromItemStack(ItemResources.loadItem("pets/lion-item"))
- )
- }
-
- @Test
- fun testPetInUI() {
- Assertions.assertEquals(
- ItemType.PET,
- ItemType.fromItemStack(ItemResources.loadItem("pets/rabbit-selected"))
- )
- Assertions.assertEquals(
- ItemType.PET,
- ItemType.fromItemStack(ItemResources.loadItem("pets/mithril-golem-not-selected"))
- )
- }
-
- @Test
- fun testAOTV() {
- Assertions.assertEquals(
- ItemType.SWORD,
- ItemType.fromItemStack(ItemResources.loadItem("aspect-of-the-void"))
- )
- }
-
- @Test
- fun testDrill() {
- Assertions.assertEquals(
- ItemType.DRILL,
- ItemType.fromItemStack(ItemResources.loadItem("titanium-drill"))
- )
- }
-
- @Test
- fun testPickaxe() {
- Assertions.assertEquals(
- ItemType.PICKAXE,
- ItemType.fromItemStack(ItemResources.loadItem("diamond-pickaxe"))
- )
- }
-}
+class ItemTypeTest
+ : ShouldSpec(
+ {
+ context("ItemType.fromItemstack") {
+ listOf(
+ "pets/lion-item" to ItemType.PET,
+ "pets/rabbit-selected" to ItemType.PET,
+ "pets/mithril-golem-not-selected" to ItemType.PET,
+ "aspect-of-the-void" to ItemType.SWORD,
+ "titanium-drill" to ItemType.DRILL,
+ "diamond-pickaxe" to ItemType.PICKAXE,
+ "gemstone-gauntlet" to ItemType.GAUNTLET,
+ ).forEach { (name, typ) ->
+ should("return $typ for $name") {
+ ItemType.fromItemStack(ItemResources.loadItem(name)) shouldBe typ
+ }
+ }
+ }
+ })
diff --git a/src/test/kotlin/util/skyblock/SackUtilTest.kt b/src/test/kotlin/util/skyblock/SackUtilTest.kt
index e1b106e..f93cd2b 100644
--- a/src/test/kotlin/util/skyblock/SackUtilTest.kt
+++ b/src/test/kotlin/util/skyblock/SackUtilTest.kt
@@ -2,7 +2,6 @@ package moe.nea.firmament.test.util.skyblock
import io.kotest.core.spec.style.AnnotationSpec
import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
import moe.nea.firmament.test.testutil.ItemResources
import moe.nea.firmament.util.skyblock.SackUtil
import moe.nea.firmament.util.skyblock.SkyBlockItems