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.

PartProcessorTest.kt 1.4KB

12345678910111213141516171819202122232425262728293031323334
  1. package com.dmdirc.ktirc.messages
  2. import com.dmdirc.ktirc.events.ChannelParted
  3. import com.dmdirc.ktirc.model.IrcMessage
  4. import com.dmdirc.ktirc.model.User
  5. import org.junit.jupiter.api.Assertions
  6. import org.junit.jupiter.api.Test
  7. internal class PartProcessorTest {
  8. @Test
  9. fun `PartProcessor raises part event without message`() {
  10. val events = PartProcessor().process(
  11. IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PART", listOf("#crashandburn".toByteArray())))
  12. Assertions.assertEquals(1, events.size)
  13. Assertions.assertEquals(ChannelParted(User("acidburn", "libby", "root.localhost"), "#crashandburn"), events[0])
  14. }
  15. @Test
  16. fun `PartProcessor raises part event with message`() {
  17. val events = PartProcessor().process(
  18. IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PART", listOf("#crashandburn".toByteArray(), "Hack the planet!".toByteArray())))
  19. Assertions.assertEquals(1, events.size)
  20. Assertions.assertEquals(ChannelParted(User("acidburn", "libby", "root.localhost"), "#crashandburn", "Hack the planet!"), events[0])
  21. }
  22. @Test
  23. fun `PartProcessor does nothing if prefix missing`() {
  24. val events = JoinProcessor().process(
  25. IrcMessage(emptyMap(), null, "PART", listOf("#crashandburn".toByteArray())))
  26. Assertions.assertEquals(0, events.size)
  27. }
  28. }