You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SimplexArchitecture/Internal/ActionTransition.swift
+30-3Lines changed: 30 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,29 @@
1
1
import Foundation
2
2
3
+
/// ``ActionTransition`` represents a transition between states in a reducer. It captures the previous and next states, the associated side effect,effect context, and the action triggering the transition.
3
4
structActionTransition<Reducer:ReducerProtocol>{
5
+
/// Represents a state. It includes the target state and the reducer state.
4
6
structState{
5
7
letstate:Reducer.Target.States?
6
8
letreducerState:Reducer.ReducerState?
7
9
}
8
-
10
+
/// The previous state.
9
11
letprevious:Self.State
12
+
/// The next state.
10
13
letnext:Self.State
14
+
/// The associated side effect.
11
15
leteffect:SideEffect<Reducer>
16
+
/// The unique effect context that represents parent effect.
12
17
leteffectContext:UUID
18
+
/// The Action that cause a change of state
13
19
letaction:CombineAction<Reducer>
14
20
21
+
/// - Parameters:
22
+
/// - previous: The previous state.
23
+
/// - next: The next state.
24
+
/// - effect: The unique effect context that represents parent effect.
25
+
/// - effectContext: The unique effect context that represents parent effect.
26
+
/// - action: The action responsible for the transition.
target.store.sentFromEffectActions.filter{ actionTransition in
12
21
!testedActions.contains{
@@ -16,8 +25,15 @@ public final class TestStore<Reducer: ReducerProtocol> where Reducer.Action: Equ
16
25
}
17
26
18
27
lettarget:Reducer.Target
28
+
29
+
/// The states of the target.
19
30
letstates:Reducer.Target.States
20
31
32
+
/// Initializes a new test store.
33
+
///
34
+
/// - Parameters:
35
+
/// - target: The target Reducer.
36
+
/// - states: The states of the target Reducer.
21
37
init(
22
38
target:Reducer.Target,
23
39
states:Reducer.Target.States
@@ -47,6 +63,12 @@ public final class TestStore<Reducer: ReducerProtocol> where Reducer.Action: Equ
47
63
}
48
64
}
49
65
66
+
/// Asserts an action was received from an effect and asserts how the state changes.
67
+
///
68
+
/// - Parameters:
69
+
/// - action: An action expected from an effect.
70
+
/// - timeout: The amount of time to wait for the expected action.
71
+
/// - expected: A closure that asserts state changed by sending the action to the store. The mutable state sent to this closure must be modified to match the state of the store after processing the given action. Do not provide a closure if no change is expected.
50
72
publicfunc receive(
51
73
_ action:Reducer.ReducerAction,
52
74
timeout:TimeInterval=5,
@@ -63,6 +85,12 @@ public final class TestStore<Reducer: ReducerProtocol> where Reducer.Action: Equ
63
85
)
64
86
}
65
87
88
+
/// Asserts an action was received from an effect and asserts how the state changes.
89
+
///
90
+
/// - Parameters:
91
+
/// - action: An action expected from an effect.
92
+
/// - timeout: The amount of time to wait for the expected action.
93
+
/// - expected: A closure that asserts state changed by sending the action to the store. The mutable state sent to this closure must be modified to match the state of the store after processing the given action. Do not provide a closure if no change is expected.
66
94
publicfunc receive(
67
95
_ action:Reducer.Action,
68
96
timeout:TimeInterval=5,
@@ -107,9 +135,7 @@ public final class TestStore<Reducer: ReducerProtocol> where Reducer.Action: Equ
0 commit comments