|
@@ -1,6 +1,9 @@
|
1
|
1
|
package com.dmdirc.ktirc.messages
|
2
|
2
|
|
3
|
3
|
import com.dmdirc.ktirc.TestConstants
|
|
4
|
+import com.dmdirc.ktirc.events.ActionReceived
|
|
5
|
+import com.dmdirc.ktirc.events.CtcpReceived
|
|
6
|
+import com.dmdirc.ktirc.events.MessageReceived
|
4
|
7
|
import com.dmdirc.ktirc.model.IrcMessage
|
5
|
8
|
import com.dmdirc.ktirc.model.User
|
6
|
9
|
import com.dmdirc.ktirc.util.currentTimeProvider
|
|
@@ -21,10 +24,78 @@ internal class PrivmsgProcessorTest {
|
21
|
24
|
IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PRIVMSG", listOf("#crashandburn".toByteArray(), "hack the planet!".toByteArray())))
|
22
|
25
|
assertEquals(1, events.size)
|
23
|
26
|
|
24
|
|
- assertEquals(TestConstants.time, events[0].time)
|
25
|
|
- assertEquals(User("acidburn", "libby", "root.localhost"), events[0].user)
|
26
|
|
- assertEquals("#crashandburn", events[0].target)
|
27
|
|
- assertEquals("hack the planet!", events[0].message)
|
|
27
|
+ val event = events[0] as MessageReceived
|
|
28
|
+ assertEquals(TestConstants.time, event.time)
|
|
29
|
+ assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
|
|
30
|
+ assertEquals("#crashandburn", event.target)
|
|
31
|
+ assertEquals("hack the planet!", event.message)
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ @Test
|
|
35
|
+ fun `PrivsgProcessor raises action received event with content`() {
|
|
36
|
+ val events = PrivmsgProcessor().process(
|
|
37
|
+ IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PRIVMSG", listOf("#crashandburn".toByteArray(), "\u0001ACTION hacks the planet\u0001".toByteArray())))
|
|
38
|
+ assertEquals(1, events.size)
|
|
39
|
+
|
|
40
|
+ val event = events[0] as ActionReceived
|
|
41
|
+ assertEquals(TestConstants.time, event.time)
|
|
42
|
+ assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
|
|
43
|
+ assertEquals("#crashandburn", event.target)
|
|
44
|
+ assertEquals("hacks the planet", event.action)
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ @Test
|
|
48
|
+ fun `PrivsgProcessor raises action received event without content`() {
|
|
49
|
+ val events = PrivmsgProcessor().process(
|
|
50
|
+ IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PRIVMSG", listOf("#crashandburn".toByteArray(), "\u0001ACTION\u0001".toByteArray())))
|
|
51
|
+ assertEquals(1, events.size)
|
|
52
|
+
|
|
53
|
+ val event = events[0] as ActionReceived
|
|
54
|
+ assertEquals(TestConstants.time, event.time)
|
|
55
|
+ assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
|
|
56
|
+ assertEquals("#crashandburn", event.target)
|
|
57
|
+ assertEquals("", event.action)
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ @Test
|
|
61
|
+ fun `PrivsgProcessor raises action received event with lowercase type`() {
|
|
62
|
+ val events = PrivmsgProcessor().process(
|
|
63
|
+ IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PRIVMSG", listOf("#crashandburn".toByteArray(), "\u0001action hacks the planet\u0001".toByteArray())))
|
|
64
|
+ assertEquals(1, events.size)
|
|
65
|
+
|
|
66
|
+ val event = events[0] as ActionReceived
|
|
67
|
+ assertEquals(TestConstants.time, event.time)
|
|
68
|
+ assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
|
|
69
|
+ assertEquals("#crashandburn", event.target)
|
|
70
|
+ assertEquals("hacks the planet", event.action)
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ @Test
|
|
74
|
+ fun `PrivsgProcessor raises CTCP received event with content`() {
|
|
75
|
+ val events = PrivmsgProcessor().process(
|
|
76
|
+ IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PRIVMSG", listOf("#crashandburn".toByteArray(), "\u0001PING 12345\u0001".toByteArray())))
|
|
77
|
+ assertEquals(1, events.size)
|
|
78
|
+
|
|
79
|
+ val event = events[0] as CtcpReceived
|
|
80
|
+ assertEquals(TestConstants.time, event.time)
|
|
81
|
+ assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
|
|
82
|
+ assertEquals("#crashandburn", event.target)
|
|
83
|
+ assertEquals("PING", event.type)
|
|
84
|
+ assertEquals("12345", event.content)
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ @Test
|
|
88
|
+ fun `PrivsgProcessor raises CTCP received event without content`() {
|
|
89
|
+ val events = PrivmsgProcessor().process(
|
|
90
|
+ IrcMessage(emptyMap(), "acidburn!libby@root.localhost".toByteArray(), "PRIVMSG", listOf("#crashandburn".toByteArray(), "\u0001PING\u0001".toByteArray())))
|
|
91
|
+ assertEquals(1, events.size)
|
|
92
|
+
|
|
93
|
+ val event = events[0] as CtcpReceived
|
|
94
|
+ assertEquals(TestConstants.time, event.time)
|
|
95
|
+ assertEquals(User("acidburn", "libby", "root.localhost"), event.user)
|
|
96
|
+ assertEquals("#crashandburn", event.target)
|
|
97
|
+ assertEquals("PING", event.type)
|
|
98
|
+ assertEquals("", event.content)
|
28
|
99
|
}
|
29
|
100
|
|
30
|
101
|
@Test
|