diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-13 17:32:10 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-13 17:32:10 +0200 |
commit | e6142bb93619dee768fc18b87ffdd28558d4bcab (patch) | |
tree | 03df79712151f7579cd683c8340741ebb3191822 /src/test/kotlin/util | |
parent | daa63bd914a2f6c5e9b668abb8474884685ee818 (diff) | |
download | Firmament-e6142bb93619dee768fc18b87ffdd28558d4bcab.tar.gz Firmament-e6142bb93619dee768fc18b87ffdd28558d4bcab.tar.bz2 Firmament-e6142bb93619dee768fc18b87ffdd28558d4bcab.zip |
Make pickaxe ability display use AbilityUtils
[no changelog]
Diffstat (limited to 'src/test/kotlin/util')
-rw-r--r-- | src/test/kotlin/util/ColorCodeTest.kt | 59 | ||||
-rw-r--r-- | src/test/kotlin/util/skyblock/AbilityUtilsTest.kt | 79 |
2 files changed, 138 insertions, 0 deletions
diff --git a/src/test/kotlin/util/ColorCodeTest.kt b/src/test/kotlin/util/ColorCodeTest.kt new file mode 100644 index 0000000..d9de36a --- /dev/null +++ b/src/test/kotlin/util/ColorCodeTest.kt @@ -0,0 +1,59 @@ +package moe.nea.firmament.test.util + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import net.minecraft.Bootstrap +import net.minecraft.SharedConstants +import moe.nea.firmament.util.removeColorCodes + + +class ColorCodeTest { + @Test + fun testWhatever() { + Assertions.assertEquals("", "".removeColorCodes().toString()) + Assertions.assertEquals("", "§".removeColorCodes().toString()) + Assertions.assertEquals("", "§a".removeColorCodes().toString()) + Assertions.assertEquals("ab", "a§ab".removeColorCodes().toString()) + Assertions.assertEquals("ab", "a§ab§§".removeColorCodes().toString()) + Assertions.assertEquals("abc", "a§ab§§c".removeColorCodes().toString()) + Assertions.assertEquals("bc", "§ab§§c".removeColorCodes().toString()) + Assertions.assertEquals("b§lc", "§ab§l§§c".removeColorCodes(true).toString()) + Assertions.assertEquals("b§lc§l", "§ab§l§§c§l".removeColorCodes(true).toString()) + Assertions.assertEquals("§lb§lc", "§l§ab§l§§c".removeColorCodes(true).toString()) + } + + @Test + fun testEdging() { + Assertions.assertEquals("", "§".removeColorCodes()) + Assertions.assertEquals("a", "a§".removeColorCodes()) + Assertions.assertEquals("b", "§ab§".removeColorCodes()) + } + + @Test + fun `testDouble§`() { + Assertions.assertEquals("1", "§§1".removeColorCodes()) + } + + @Test + fun testKeepNonColor() { + Assertions.assertEquals("§k§l§m§n§o§r", "§k§l§m§f§n§o§r".removeColorCodes(true)) + } + + @Test + fun testPlainString() { + Assertions.assertEquals("bcdefgp", "bcdefgp".removeColorCodes()) + Assertions.assertEquals("", "".removeColorCodes()) + } + + @Test + fun testSomeNormalTestCases() { + Assertions.assertEquals( + "You are not currently in a party.", + "§r§cYou are not currently in a party.§r".removeColorCodes() + ) + Assertions.assertEquals( + "Ancient Necron's Chestplate ✪✪✪✪", + "§dAncient Necron's Chestplate §6✪§6✪§6✪§6✪".removeColorCodes() + ) + } +} diff --git a/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt new file mode 100644 index 0000000..abe739d --- /dev/null +++ b/src/test/kotlin/util/skyblock/AbilityUtilsTest.kt @@ -0,0 +1,79 @@ +package moe.nea.firmament.test.util.skyblock + +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 +import moe.nea.firmament.test.testutil.ItemResources +import moe.nea.firmament.util.skyblock.AbilityUtils +import moe.nea.firmament.util.unformattedString + +class AbilityUtilsTest { + + fun List<AbilityUtils.ItemAbility>.stripDescriptions() = map { + it.copy(descriptionLines = it.descriptionLines.map { Text.literal(it.unformattedString) }) + } + + @Test + fun testUnpoweredDrill() { + Assertions.assertEquals( + listOf( + AbilityUtils.ItemAbility( + "Pickobulus", + 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), + 48.seconds + ) + ), + AbilityUtils.getAbilities(ItemResources.loadItem("titanium-drill")).stripDescriptions() + ) + } + + @Test + fun testPoweredPickaxe() { + Assertions.assertEquals( + listOf( + AbilityUtils.ItemAbility( + "Mining Speed Boost", + true, + AbilityUtils.AbilityActivation.RIGHT_CLICK, + null, + listOf("Grants +200% ⸕ Mining Speed for", + "10s.").map(Text::literal), + 2.minutes + ) + ), + AbilityUtils.getAbilities(ItemResources.loadItem("diamond-pickaxe")).stripDescriptions() + ) + } + + @Test + fun testAOTV() { + Assertions.assertEquals( + 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), + null + ), + AbilityUtils.ItemAbility( + "Ether Transmission", + false, + AbilityUtils.AbilityActivation.SNEAK_RIGHT_CLICK, + 90, + listOf("Teleport to your targeted block up", + "to 61 blocks away.", + "Soulflow Cost: 1").map(Text::literal), + null + ) + ), + AbilityUtils.getAbilities(ItemResources.loadItem("aspect-of-the-void")).stripDescriptions() + ) + } +} |