Merge pull request #3107 from Multiverse/ben/mv5/version-cmd-test

Add tests for version command
This commit is contained in:
Ben Woo 2024-10-12 13:37:47 +08:00 committed by GitHub
commit 18f4600ca4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,36 @@
package org.mvplugins.multiverse.core.commands
import be.seeseemelk.mockbukkit.entity.PlayerMock
import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.mvplugins.multiverse.core.TestWithMockBukkit
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class VersionCommandTest : TestWithMockBukkit() {
private lateinit var player: PlayerMock
@BeforeTest
fun setUp() {
player = server.addPlayer("benwoo1110");
assertEquals(player, server.getPlayer("benwoo1110"))
}
@Test
fun `Run version command as console`() {
val console = server.consoleSender;
assertTrue(Bukkit.dispatchCommand(console, "mv version"))
val output = ChatColor.stripColor(console.nextMessage())
assertEquals("Multiverse Core Version vlocal", output)
}
@Test
fun `Run version command as player`() {
assertTrue(player.performCommand("mv version"))
val output = ChatColor.stripColor(player.nextMessage())
assertEquals("I'm sorry, but you do not have permission to perform this command.", output)
}
}