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.

ServerStateHandlerTest.kt 1.4KB

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