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

[Ci skip] Added some more basic tests

This commit is contained in:
TheBusyBiscuit 2020-05-26 09:57:45 +02:00
parent 1b951f77ea
commit 4af26f3b00
7 changed files with 84 additions and 4 deletions

View File

@ -44,6 +44,14 @@ public interface SlimefunGuideImplementation {
*/
ItemStack getItem();
/**
* This method returns whether this {@link SlimefunGuideImplementation} is meant
* for Survival Mode.
*
* @return Whether this is a survival mode implementation
*/
boolean isSurvivalMode();
void openMainMenu(PlayerProfile profile, int page);
void openCategory(PlayerProfile profile, Category category, int page);

View File

@ -42,6 +42,11 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
return SlimefunGuideLayout.BOOK;
}
@Override
public boolean isSurvivalMode() {
return true;
}
@Override
public ItemStack getItem() {
return new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&aSlimefun Guide &7(Book GUI)", "", "&eRight Click &8\u21E8 &7Browse Items", "&eShift + Right Click &8\u21E8 &7Open Settings / Credits");

View File

@ -14,7 +14,7 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
}
@Override
protected boolean isSurvivalMode() {
public boolean isSurvivalMode() {
return false;
}

View File

@ -75,7 +75,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
return new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&aSlimefun Guide &7(Chest GUI)", "", "&eRight Click &8\u21E8 &7Browse Items", "&eShift + Right Click &8\u21E8 &7Open Settings / Credits");
}
protected boolean isSurvivalMode() {
@Override
public boolean isSurvivalMode() {
return true;
}

View File

@ -0,0 +1,34 @@
package io.github.thebusybiscuit.slimefun4.tests.guide;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import be.seeseemelk.mockbukkit.MockBukkit;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
public class TestBookSlimefunGuide {
@BeforeAll
public static void load() {
MockBukkit.mock();
MockBukkit.load(SlimefunPlugin.class);
}
@AfterAll
public static void unload() {
MockBukkit.unmock();
}
@Test
public void testBasicGetters() {
BookSlimefunGuide guide = new BookSlimefunGuide();
Assertions.assertEquals(SlimefunGuideLayout.BOOK, guide.getLayout());
Assertions.assertTrue(guide.isSurvivalMode());
}
}

View File

@ -0,0 +1,34 @@
package io.github.thebusybiscuit.slimefun4.tests.guide;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import be.seeseemelk.mockbukkit.MockBukkit;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
public class TestChestSlimefunGuide {
@BeforeAll
public static void load() {
MockBukkit.mock();
MockBukkit.load(SlimefunPlugin.class);
}
@AfterAll
public static void unload() {
MockBukkit.unmock();
}
@Test
public void testBasicGetters() {
ChestSlimefunGuide guide = new ChestSlimefunGuide(false);
Assertions.assertEquals(SlimefunGuideLayout.CHEST, guide.getLayout());
Assertions.assertTrue(guide.isSurvivalMode());
}
}

View File

@ -2,7 +2,6 @@ package io.github.thebusybiscuit.slimefun4.tests.services;
import java.io.File;
import org.bukkit.plugin.PluginDescriptionFile;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@ -12,7 +11,6 @@ import be.seeseemelk.mockbukkit.MockBukkit;
import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch;
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import org.mockito.Mock;
public class TestUpdaterService {