Skip to content

Commit

Permalink
Added tests for openGUI with meta function
Browse files Browse the repository at this point in the history
  • Loading branch information
fulminazzo committed Apr 13, 2024
1 parent 95ea71d commit 6901444
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gui/bukkit/src/test/java/it/angrybear/yagl/GUIAdapterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import it.fulminazzo.fulmicollection.objects.Refl;
import it.fulminazzo.jbukkit.BukkitUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -86,6 +88,24 @@ void testOpenGUI(GUI expected) {
}
}

@Test
void testOpenGUIMeta() {
GUI gui = GUI.newGUI(GUIType.CHEST)
.setTitle(null)
.addContent(Item.newItem(Material.PLAYER_HEAD.name()).setDisplayName("test"));
GUITestUtils.mockPlugin(p -> GUIAdapter.openGUI(gui, GUIManager.getViewer(this.player), m -> m.setUnbreakable(true)));

assertNotNull(this.inventory);

ItemStack expected = new ItemStack(Material.PLAYER_HEAD);
ItemMeta meta = expected.getItemMeta();
meta.setDisplayName("test");
meta.setUnbreakable(true);
expected.setItemMeta(meta);

assertEquals(expected, this.inventory.getItem(0));
}

@Test
void testOpenGUIRequirements() {
when(this.player.hasPermission(anyString())).thenReturn(false);
Expand Down

0 comments on commit 6901444

Please sign in to comment.