Skip to content

Commit 245c371

Browse files
committed
added more tests
1 parent abbfb7b commit 245c371

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

ReactiveDataDisplayManagerTests/Utils/BaseEventTests.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ import XCTest
1010

1111
final class BaseEventTests: XCTestCase {
1212

13+
func testWhenValueInvokesCorrectly() {
14+
// given
15+
16+
let event = BaseEvent<String>()
17+
var result = ""
18+
19+
event.addListner { result = $0 }
20+
21+
// when
22+
23+
event.invoke(with: "invoked")
24+
25+
// then
26+
27+
XCTAssertEqual(result, "invoked")
28+
}
29+
1330
func testWhenNListnersThenNEvents() {
1431
// given
1532

@@ -91,4 +108,23 @@ final class BaseEventTests: XCTestCase {
91108
XCTAssertEqual(event.count, n)
92109
}
93110

111+
func testWhenClearThenNoEvents() {
112+
// given
113+
114+
let event = BaseEvent<Int>()
115+
var result = false
116+
117+
event.addListner { _ in result = true }
118+
119+
// when
120+
121+
event.clear()
122+
event.invoke(with: 0)
123+
124+
// then
125+
126+
XCTAssertFalse(result)
127+
XCTAssertTrue(event.isEmpty)
128+
}
129+
94130
}

0 commit comments

Comments
 (0)