Skip to content

Commit 12cb3b8

Browse files
committed
[Test] Add testHasRoute_anyEvent()
1 parent 439d5a8 commit 12cb3b8

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

SwiftStateTests/TryEventTests.swift

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class TryEventTests: _TestCase
116116

117117
// Fix for transitioning of routes w/ multiple from-states
118118
// https://github.com/ReactKit/SwiftState/pull/32
119-
func testTryEvent_issue32() {
119+
func testTryEvent_issue32()
120+
{
120121
let machine = Machine<MyState, MyEvent>(state: .State0) { machine in
121122
machine.addRouteEvent(.Event0, transitions: [ .State0 => .State1 ])
122123
machine.addRouteEvent(.Event1, routes: [ [ .State1, .State2 ] => .State3 ])
@@ -131,6 +132,31 @@ class TryEventTests: _TestCase
131132
XCTAssertEqual(machine.state, MyState.State3)
132133
}
133134

135+
// MARK: hasRoute + event
136+
137+
func testHasRoute_anyEvent()
138+
{
139+
({
140+
let machine = Machine<MyState, MyEvent>(state: .State0) { machine in
141+
machine.addRoute(.State0 => .State1)
142+
machine.addRouteEvent(.Any, transitions: [.State0 => .State1])
143+
}
144+
145+
let hasRoute = machine.hasRoute(.State0 => .State1, forEvent: .Event0)
146+
XCTAssertTrue(hasRoute)
147+
})()
148+
149+
({
150+
let machine = Machine<MyState, MyEvent>(state: .State0) { machine in
151+
machine.addRoute(.State0 => .State1)
152+
machine.addRouteEvent(.Any, transitions: [.State2 => .State3])
153+
}
154+
155+
let hasRoute = machine.hasRoute(.State0 => .State1, forEvent: .Event0)
156+
XCTAssertFalse(hasRoute)
157+
})()
158+
}
159+
134160
// Fix hasRoute() bug when there are routes for no-event & with-event.
135161
// https://github.com/ReactKit/SwiftState/pull/19
136162
func testHasRoute_issue19()

0 commit comments

Comments
 (0)