diff options
Diffstat (limited to 'src/test/kotlin/util/skyblock')
-rw-r--r-- | src/test/kotlin/util/skyblock/AbilityUtilsTest.kt | 31 | ||||
-rw-r--r-- | src/test/kotlin/util/skyblock/ItemTypeTest.kt | 67 | ||||
-rw-r--r-- | src/test/kotlin/util/skyblock/SackUtilTest.kt | 3 | ||||
-rw-r--r-- | src/test/kotlin/util/skyblock/TabListAPITest.kt | 48 | ||||
-rw-r--r-- | src/test/kotlin/util/skyblock/TimestampTest.kt | 28 |
5 files changed, 117 insertions, 60 deletions
diff --git a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt index dbce762..9d25aad 100644 --- a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt +++ b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt @@ -1,6 +1,5 @@ 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 @@ -10,7 +9,7 @@ import moe.nea.firmament.test.testutil.ItemResources import moe.nea.firmament.util.skyblock.AbilityUtils import moe.nea.firmament.util.unformattedString -class AbilityUtilsTest : AnnotationSpec() { +class AbilityUtilsTest { fun List<AbilityUtils.ItemAbility>.stripDescriptions() = map { it.copy(descriptionLines = it.descriptionLines.map { Text.literal(it.unformattedString) }) @@ -25,9 +24,11 @@ class AbilityUtilsTest : AnnotationSpec() { false, AbilityUtils.AbilityActivation.RIGHT_CLICK, null, - listOf("Throw your pickaxe to create an", - "explosion mining all ores in a 3 block", - "radius.").map(Text::literal), + listOf( + "Throw your pickaxe to create an", + "explosion mining all ores in a 3 block", + "radius." + ).map(Text::literal), 48.seconds ) ), @@ -44,8 +45,10 @@ class AbilityUtilsTest : AnnotationSpec() { true, AbilityUtils.AbilityActivation.RIGHT_CLICK, null, - listOf("Grants +200% ⸕ Mining Speed for", - "10s.").map(Text::literal), + listOf( + "Grants +200% ⸕ Mining Speed for", + "10s." + ).map(Text::literal), 2.minutes ) ), @@ -59,8 +62,10 @@ class AbilityUtilsTest : AnnotationSpec() { listOf( AbilityUtils.ItemAbility( "Instant Transmission", true, AbilityUtils.AbilityActivation.RIGHT_CLICK, 23, - listOf("Teleport 12 blocks ahead of you and", - "gain +50 ✦ Speed for 3 seconds.").map(Text::literal), + listOf( + "Teleport 12 blocks ahead of you and", + "gain +50 ✦ Speed for 3 seconds." + ).map(Text::literal), null ), AbilityUtils.ItemAbility( @@ -68,9 +73,11 @@ class AbilityUtilsTest : AnnotationSpec() { false, AbilityUtils.AbilityActivation.SNEAK_RIGHT_CLICK, 90, - listOf("Teleport to your targeted block up", - "to 61 blocks away.", - "Soulflow Cost: 1").map(Text::literal), + listOf( + "Teleport to your targeted block up", + "to 61 blocks away.", + "Soulflow Cost: 1" + ).map(Text::literal), null ) ), diff --git a/src/test/kotlin/util/skyblock/ItemTypeTest.kt b/src/test/kotlin/util/skyblock/ItemTypeTest.kt index c89e57d..c0ef2a3 100644 --- a/src/test/kotlin/util/skyblock/ItemTypeTest.kt +++ b/src/test/kotlin/util/skyblock/ItemTypeTest.kt @@ -1,53 +1,28 @@ 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 org.junit.jupiter.api.DynamicTest +import org.junit.jupiter.api.TestFactory 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 { + @TestFactory + fun 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, + ).map { (name, typ) -> + DynamicTest.dynamicTest("return $typ for $name") { + Assertions.assertEquals( + typ, + ItemType.fromItemStack(ItemResources.loadItem(name)) + ) + } + } } diff --git a/src/test/kotlin/util/skyblock/SackUtilTest.kt b/src/test/kotlin/util/skyblock/SackUtilTest.kt index e1b106e..e0e3e63 100644 --- a/src/test/kotlin/util/skyblock/SackUtilTest.kt +++ b/src/test/kotlin/util/skyblock/SackUtilTest.kt @@ -1,13 +1,12 @@ 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 -class SackUtilTest : AnnotationSpec() { +class SackUtilTest { @Test fun testOneRottenFlesh() { Assertions.assertEquals( diff --git a/src/test/kotlin/util/skyblock/TabListAPITest.kt b/src/test/kotlin/util/skyblock/TabListAPITest.kt new file mode 100644 index 0000000..26eafe0 --- /dev/null +++ b/src/test/kotlin/util/skyblock/TabListAPITest.kt @@ -0,0 +1,48 @@ +package moe.nea.firmament.test.util.skyblock + +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.TabListAPI + +class TabListAPITest { + val tablist = ItemResources.loadTablist("dungeon_hub") + + @Test + fun checkWithTitle() { + Assertions.assertEquals( + listOf( + "Profile: Strawberry", + " SB Level: [210] 26/100 XP", + " Bank: 1.4B", + " Interest: 12 Hours (689.1k)", + ), + TabListAPI.getWidgetLines(TabListAPI.WidgetName.PROFILE, includeTitle = true, from = tablist).map { it.string }) + } + + @Test + fun checkEndOfColumn() { + Assertions.assertEquals( + listOf( + " Bonzo IV: 110/150", + " Scarf II: 25/50", + " The Professor IV: 141/150", + " Thorn I: 29/50", + " Livid II: 91/100", + " Sadan V: 388/500", + " Necron VI: 531/750", + ), + TabListAPI.getWidgetLines(TabListAPI.WidgetName.COLLECTION, from = tablist).map { it.string } + ) + } + + @Test + fun checkWithoutTitle() { + Assertions.assertEquals( + listOf( + " Undead: 1,907", + " Wither: 318", + ), + TabListAPI.getWidgetLines(TabListAPI.WidgetName.ESSENCE, from = tablist).map { it.string }) + } +} diff --git a/src/test/kotlin/util/skyblock/TimestampTest.kt b/src/test/kotlin/util/skyblock/TimestampTest.kt new file mode 100644 index 0000000..b960cb9 --- /dev/null +++ b/src/test/kotlin/util/skyblock/TimestampTest.kt @@ -0,0 +1,28 @@ +package moe.nea.firmament.test.util.skyblock + +import java.time.Instant +import java.time.ZonedDateTime +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import moe.nea.firmament.test.testutil.ItemResources +import moe.nea.firmament.util.SBData +import moe.nea.firmament.util.timestamp + +class TimestampTest { + + @Test + fun testLongTimestamp() { + Assertions.assertEquals( + Instant.ofEpochSecond(1658091600), + ItemResources.loadItem("hyperion").timestamp + ) + } + + @Test + fun testStringTimestamp() { + Assertions.assertEquals( + ZonedDateTime.of(2021, 10, 11, 15, 39, 0, 0, SBData.hypixelTimeZone).toInstant(), + ItemResources.loadItem("backpack-in-menu").timestamp + ) + } +} |