#1121: Add unit test for spawn egg meta

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot 2022-12-13 19:04:30 +11:00
parent c0d9b8db7c
commit 37d4b08ff4

View file

@ -29,6 +29,7 @@ import org.bukkit.craftbukkit.inventory.ItemStackTest.BukkitWrapper;
import org.bukkit.craftbukkit.inventory.ItemStackTest.CraftWrapper;
import org.bukkit.craftbukkit.inventory.ItemStackTest.StackProvider;
import org.bukkit.craftbukkit.inventory.ItemStackTest.StackWrapper;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Axolotl;
import org.bukkit.entity.TropicalFish;
@ -48,6 +49,7 @@ import org.bukkit.inventory.meta.KnowledgeBookMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.inventory.meta.TropicalFishBucketMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffectType;
@ -184,6 +186,21 @@ public class ItemMetaTest extends AbstractTestingBase {
}
}
@Test
public void testSpawnEggsHasMeta() {
for (Item item : BuiltInRegistries.ITEM) {
if (item instanceof net.minecraft.world.item.ItemMonsterEgg) {
Material material = CraftMagicNumbers.getMaterial(item);
CraftMetaItem baseMeta = (CraftMetaItem) Bukkit.getItemFactory().getItemMeta(material);
ItemMeta baseMetaItem = CraftItemStack.getItemMeta(item.getDefaultInstance());
assertTrue(material + " is not handled in CraftItemFactory", baseMeta instanceof CraftMetaSpawnEgg);
assertTrue(material + " is not applicable to CraftMetaSpawnEgg", baseMeta.applicableTo(material));
assertTrue(material + " is not handled in CraftItemStack", baseMetaItem instanceof SpawnEggMeta);
}
}
}
@Test
public void testEachExtraData() {
final List<StackProvider> providers = Arrays.asList(