Test item snbt in tag

This commit is contained in:
themode 2022-04-07 15:26:45 +02:00
parent 60d22929a1
commit 3c2ef39d1b

View File

@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test;
import java.lang.ref.WeakReference;
import static net.minestom.server.api.TestUtils.assertEqualsSNBT;
import static net.minestom.server.api.TestUtils.waitUntilCleared;
import static org.junit.jupiter.api.Assertions.*;
@ -91,4 +92,22 @@ public class TagItemTest {
assertEquals(item2.toItemNBT(), handler.getTag(nbtTag));
}
}
@Test
public void snbt() {
var handler = TagHandler.newHandler();
var tag = Tag.ItemStack("item");
handler.setTag(tag, ItemStack.of(Material.DIAMOND));
assertEqualsSNBT("""
{
"item": {
"id":"minecraft:diamond",
"Count":1B,
"tag":{}
}
}
""", handler.asCompound());
handler.removeTag(tag);
assertEqualsSNBT("{}", handler.asCompound());
}
}