File tree 1 file changed +21
-0
lines changed
Tests/D2HandlersTests/message/handler
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
import XCTest
2
+ import D2MessageIO
3
+ import D2TestUtils
2
4
@testable import D2Handlers
3
5
4
6
final class LuckyNumberHandlerTests : XCTestCase {
@@ -19,4 +21,23 @@ final class LuckyNumberHandlerTests: XCTestCase {
19
21
XCTAssertTrue ( handler. isLucky ( 42 ) )
20
22
XCTAssertTrue ( handler. isLucky ( 420 ) )
21
23
}
24
+
25
+ func testMessageTrigger( ) {
26
+ let handler = LuckyNumberHandler ( luckyNumbers: [ 42 ] )
27
+ let output = TestOutput ( )
28
+
29
+ let message = Message (
30
+ content: " 40 is a nice number and so is 2 " ,
31
+ channelId: ID ( " Dummy Channel " )
32
+ )
33
+ output. messages. append ( message)
34
+ _ = handler. handle ( message: message, from: output)
35
+
36
+ XCTAssertEqual ( output. lastContent, """
37
+ All the numbers in your message added up to 42. Congrats!
38
+ ```
39
+ 40 + 2 = 42
40
+ ```
41
+ """ )
42
+ }
22
43
}
You can’t perform that action at this time.
0 commit comments