File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,31 @@ class StateMachineEventTests: _TestCase
8686 XCTAssertEqual ( machine. state, MyState . State0)
8787 }
8888
89+ /// https://github.com/ReactKit/SwiftState/issues/28
90+ func testTryEvent_issue28( )
91+ {
92+ var eventCount = 0
93+ let machine = StateMachine < MyState , MyEvent > ( state: . State0) { machine in
94+ machine. addRoute ( . State0 => . State1)
95+ machine. addRouteEvent ( . Event0, transitions: [ nil => nil ] ) { _ in
96+ eventCount++
97+ }
98+ }
99+
100+ XCTAssertEqual ( eventCount, 0 )
101+
102+ machine <-! . Event0
103+ XCTAssertEqual ( eventCount, 1 )
104+ XCTAssertEqual ( machine. state, MyState . State0, " State should NOT be changed " )
105+
106+ machine <- . State1
107+ XCTAssertEqual ( machine. state, MyState . State1, " State should be changed " )
108+
109+ machine <-! . Event0
110+ XCTAssertEqual ( eventCount, 2 )
111+ XCTAssertEqual ( machine. state, MyState . State1, " State should NOT be changed " )
112+ }
113+
89114 func testTryEvent_string( )
90115 {
91116 let machine = StateMachine < MyState , String > ( state: . State0)
You can’t perform that action at this time.
0 commit comments