Skip to content

Commit

Permalink
Add tests for TexturedItem
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Nov 1, 2024
1 parent 26a6ab2 commit 8a28cae
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package foundation.esoteric.minecraft.plugins.library

import foundation.esoteric.minecraft.plugins.library.file.FileManagedPlugin
import foundation.esoteric.minecraft.plugins.library.file.FileManager
import foundation.esoteric.minecraft.plugins.library.item.CustomItemManager
import foundation.esoteric.minecraft.plugins.library.item.CustomItemPlugin
import org.bukkit.plugin.java.JavaPlugin

open class TestPlugin : JavaPlugin(), FileManagedPlugin {
open class TestPlugin : JavaPlugin(), FileManagedPlugin, CustomItemPlugin {

override lateinit var customItemManager: CustomItemManager
override lateinit var fileManager: FileManager

override fun onEnable() {
fileManager = FileManager(this)
customItemManager = CustomItemManager(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package foundation.esoteric.minecraft.plugins.library.item

import foundation.esoteric.minecraft.plugins.library.TestPlugin
import org.bukkit.Material

class TestTexturedItem(plugin: TestPlugin) : TexturedItem(plugin, "test_textured_item", Material.MACE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package foundation.esoteric.minecraft.plugins.library.item

import be.seeseemelk.mockbukkit.MockBukkit
import foundation.esoteric.minecraft.plugins.library.TestPlugin
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals

class TexturedItemTest {

private var plugin: TestPlugin? = null
private var testItem: TestTexturedItem? = null

@BeforeTest fun mockItemStack() {
MockBukkit.mock()
plugin = MockBukkit.load(TestPlugin::class.java)

testItem = TestTexturedItem(plugin!!)
}

@Test fun usesCorrectModelData() {
val item = testItem!!.createItem()

assertEquals(testItem!!::class.qualifiedName, "foundation.esoteric.minecraft.plugins.library.item.TestTexturedItem")
assertEquals(testItem!!::class.qualifiedName.hashCode(), "foundation.esoteric.minecraft.plugins.library.item.TestTexturedItem".hashCode())
assertEquals(item.itemMeta.customModelData, "foundation.esoteric.minecraft.plugins.library.item.TestTexturedItem".hashCode())
}

@AfterTest fun unmockItemStack() {
MockBukkit.unmock()
}
}

0 comments on commit 8a28cae

Please sign in to comment.