Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

AwayProcessorTest.kt 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.dmdirc.ktirc.messages.processors
  2. import com.dmdirc.ktirc.TestConstants
  3. import com.dmdirc.ktirc.model.IrcMessage
  4. import com.dmdirc.ktirc.model.User
  5. import com.dmdirc.ktirc.params
  6. import com.dmdirc.ktirc.util.currentTimeProvider
  7. import org.junit.jupiter.api.Assertions
  8. import org.junit.jupiter.api.Assertions.assertEquals
  9. import org.junit.jupiter.api.Assertions.assertNull
  10. import org.junit.jupiter.api.BeforeEach
  11. import org.junit.jupiter.api.Test
  12. internal class AwayProcessorTest {
  13. @BeforeEach
  14. fun setUp() {
  15. currentTimeProvider = { TestConstants.time }
  16. }
  17. @Test
  18. fun `raises away changed event with reason`() {
  19. val events = AwayProcessor().process(
  20. IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "AWAY", params("Hacking the planet")))
  21. assertEquals(1, events.size)
  22. val event = events[0]
  23. assertEquals(TestConstants.time, event.metadata.time)
  24. assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
  25. assertEquals("Hacking the planet", event.message)
  26. }
  27. @Test
  28. fun `raises away changed event with no reason`() {
  29. val events = AwayProcessor().process(
  30. IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "AWAY", emptyList()))
  31. assertEquals(1, events.size)
  32. val event = events[0]
  33. assertEquals(TestConstants.time, event.metadata.time)
  34. assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
  35. assertNull(event.message)
  36. }
  37. @Test
  38. fun `does nothing on away if prefix missing`() {
  39. val events = AwayProcessor().process(IrcMessage(emptyMap(), null, "AWAY", params("*")))
  40. Assertions.assertEquals(0, events.size)
  41. }
  42. }