Skip to content

Commit a468632

Browse files
committed
Test lucky number detection
1 parent 90a0604 commit a468632

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: Tests/D2HandlersTests/message/handler/LuckyNumberHandlerTests.swift

+21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import XCTest
2+
import D2MessageIO
3+
import D2TestUtils
24
@testable import D2Handlers
35

46
final class LuckyNumberHandlerTests: XCTestCase {
@@ -19,4 +21,23 @@ final class LuckyNumberHandlerTests: XCTestCase {
1921
XCTAssertTrue(handler.isLucky(42))
2022
XCTAssertTrue(handler.isLucky(420))
2123
}
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+
}
2243
}

0 commit comments

Comments
 (0)