Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ServerStateHandlerTest.kt 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.dmdirc.ktirc.events
  2. import com.dmdirc.ktirc.IrcClient
  3. import com.dmdirc.ktirc.model.ServerFeature
  4. import com.dmdirc.ktirc.model.ServerFeatureMap
  5. import com.dmdirc.ktirc.model.ServerState
  6. import com.nhaarman.mockitokotlin2.doReturn
  7. import com.nhaarman.mockitokotlin2.mock
  8. import kotlinx.coroutines.runBlocking
  9. import org.junit.jupiter.api.Assertions.assertEquals
  10. import org.junit.jupiter.api.Test
  11. internal class ServerStateHandlerTest {
  12. private val serverState = ServerState("")
  13. private val ircClient = mock<IrcClient> {
  14. on { serverState } doReturn serverState
  15. }
  16. private val handler = ServerStateHandler()
  17. @Test
  18. fun `ServerStateHandler sets local nickname on welcome event`() = runBlocking {
  19. handler.processEvent(ircClient, ServerWelcome("acidBurn"))
  20. assertEquals("acidBurn", serverState.localNickname)
  21. }
  22. @Test
  23. fun `ServerStateHandler updates features on features event`() = runBlocking {
  24. val features = ServerFeatureMap()
  25. features[ServerFeature.ChannelModes] = "abc"
  26. features[ServerFeature.WhoxSupport] = true
  27. handler.processEvent(ircClient, ServerFeaturesUpdated(features))
  28. assertEquals("abc", serverState.features[ServerFeature.ChannelModes])
  29. assertEquals(true, serverState.features[ServerFeature.WhoxSupport])
  30. }
  31. }