1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Add test for both normal and colored seearches

This commit is contained in:
JustAHuman-xD 2023-12-07 12:48:57 -06:00
parent d0963697ca
commit e83c9f704e

View File

@ -5,11 +5,14 @@ import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@ -90,8 +93,28 @@ class TestGuideOpening {
}
@Test
@DisplayName("Test if the Slimefun Search can be opened from the History")
@DisplayName("Test if the Slimefun Search works with normal and colored querys")
void testOpenSearch() throws InterruptedException {
String normalQuery = "iron";
String coloredQuery = ChatColor.DARK_PURPLE + "iron";
SlimefunItem testItem = TestUtilities.mockSlimefunItem(plugin, "IRON_ITEM", new CustomItemStack(Material.IRON_INGOT, "iron item"));
testItem.register(plugin);
Player player = server.addPlayer();
PlayerProfile profile = TestUtilities.awaitProfile(player);
SlimefunGuideImplementation guide = new SurvivalSlimefunGuide(false, false);
guide.openSearch(profile, normalQuery, false);
Assertions.assertTrue(player.getOpenInventory().getTopInventory().contains(testItem.getItem()), "Failed on normal query");
guide.openSearch(profile, coloredQuery, false);
Assertions.assertTrue(player.getOpenInventory().getTopInventory().contains(testItem.getItem()), "Failed on colored query");
}
@Test
@DisplayName("Test if the Slimefun Search can be opened from the History")
void testOpenSearchHistory() throws InterruptedException {
String query = "electric";
SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class);