It's a plugin for a Spigot Minecraft server to log the time players spend on the server and returns it to them.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
1.0 KiB

package listener
import PlayerService
import io.mockk.Runs
import io.mockk.confirmVerified
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import io.mockk.verify
import java.util.UUID
import org.bukkit.entity.Player
import org.bukkit.event.player.PlayerQuitEvent
import org.junit.jupiter.api.Test
class QuitListenerTest {
@Test
fun `should call to add a player`() {
val mockPlayer = mockk<Player>()
every { mockPlayer.uniqueId } returns UUID.randomUUID()
every { mockPlayer.name } returns ""
val mockPlayerQuitEvent = mockk<PlayerQuitEvent>()
every { mockPlayerQuitEvent.player } returns mockPlayer
val mockPlayerService = mockk<PlayerService>()
every { mockPlayerService.removePlayer(any()) } just Runs
val quitListener = QuitListener(mockPlayerService)
quitListener.onPlayerQuit(mockPlayerQuitEvent)
verify(exactly = 1) { mockPlayerService.removePlayer(any()) }
confirmVerified(mockPlayerService)
}
}