@@ -60,70 +60,123 @@ public struct Send<ActionType, StateType>: StepProtocol {
60
60
public init (
61
61
action: @autoclosure @escaping ( ) -> ActionType ,
62
62
file: StaticString = #file,
63
+ fileForStateMutation: StaticString = #file,
63
64
line: UInt = #line,
65
+ lineForStateMutation: UInt = #line,
64
66
stateChange: @escaping ( inout StateType ) -> Void = { _ in }
65
67
) {
66
68
self . action = action
67
69
self . file = file
70
+ self . fileForStateMutation = fileForStateMutation
68
71
self . line = line
72
+ self . lineForStateMutation = lineForStateMutation
69
73
self . stateChange = stateChange
70
74
}
71
75
72
76
let action : ( ) -> ActionType
73
77
let file : StaticString
74
78
let line : UInt
79
+ let fileForStateMutation : StaticString
80
+ let lineForStateMutation : UInt
75
81
let stateChange : ( inout StateType ) -> Void
76
82
77
83
public var asStep : Step < ActionType , StateType > {
78
- . send( action: action ( ) , file: file, line: line, stateChange: stateChange)
84
+ . send(
85
+ action: action ( ) ,
86
+ file: file,
87
+ fileForStateMutation: fileForStateMutation,
88
+ line: line,
89
+ lineForStateMutation: lineForStateMutation,
90
+ stateChange: stateChange
91
+ )
79
92
}
80
93
81
- public func expectStateToHaveChanged( _ expectedMutation: @escaping ( inout StateType ) -> Void = { _ in } ) -> Send {
82
- . init( action: action ( ) , file: file, line: line, stateChange: { state in
94
+ public func expectStateToHaveChanged(
95
+ fileForStateMutation: StaticString = #file,
96
+ lineForStateMutation: UInt = #line,
97
+ _ expectedMutation: @escaping ( inout StateType ) -> Void = { _ in }
98
+ ) -> Send {
99
+ Send (
100
+ action: action ( ) ,
101
+ file: file,
102
+ fileForStateMutation: fileForStateMutation,
103
+ line: line,
104
+ lineForStateMutation: lineForStateMutation
105
+ ) { state in
83
106
self . stateChange ( & state)
84
107
expectedMutation ( & state)
85
- } )
108
+ }
86
109
}
87
110
}
88
111
89
112
public struct Receive < ActionType, StateType> : StepProtocol {
90
- public init ( isExpectedAction: @escaping ( ActionType ) -> Bool ,
91
- file: StaticString = #file,
92
- line: UInt = #line,
93
- stateChange: @escaping ( inout StateType ) -> Void = { _ in } ) {
113
+ public init (
114
+ isExpectedAction: @escaping ( ActionType ) -> Bool ,
115
+ file: StaticString = #file,
116
+ fileForStateMutation: StaticString = #file,
117
+ line: UInt = #line,
118
+ lineForStateMutation: UInt = #line,
119
+ stateChange: @escaping ( inout StateType ) -> Void = { _ in }
120
+ ) {
94
121
self . isExpectedAction = isExpectedAction
95
122
self . file = file
123
+ self . fileForStateMutation = fileForStateMutation
96
124
self . line = line
125
+ self . lineForStateMutation = lineForStateMutation
97
126
self . stateChange = stateChange
98
127
}
99
128
100
- public init ( action: @autoclosure @escaping ( ) -> ActionType ,
101
- file: StaticString = #file,
102
- line: UInt = #line,
103
- stateChange: @escaping ( inout StateType ) -> Void = { _ in }
129
+ public init (
130
+ action: @autoclosure @escaping ( ) -> ActionType ,
131
+ file: StaticString = #file,
132
+ fileForStateMutation: StaticString = #file,
133
+ line: UInt = #line,
134
+ lineForStateMutation: UInt = #line,
135
+ stateChange: @escaping ( inout StateType ) -> Void = { _ in }
104
136
) where ActionType: Equatable {
105
137
self . init (
106
138
isExpectedAction: { $0 == action ( ) } ,
107
139
file: file,
140
+ fileForStateMutation: fileForStateMutation,
108
141
line: line,
142
+ lineForStateMutation: lineForStateMutation,
109
143
stateChange: stateChange
110
144
)
111
145
}
112
146
113
147
let file : StaticString
114
148
let line : UInt
149
+ let fileForStateMutation : StaticString
150
+ let lineForStateMutation : UInt
115
151
let stateChange : ( inout StateType ) -> Void
116
152
let isExpectedAction : ( ActionType ) -> Bool
117
153
118
154
public var asStep : Step < ActionType , StateType > {
119
- . receive( isExpectedAction: isExpectedAction, file: file, line: line, stateChange: stateChange)
155
+ . receive(
156
+ isExpectedAction: isExpectedAction,
157
+ file: file,
158
+ fileForStateMutation: fileForStateMutation,
159
+ line: line,
160
+ lineForStateMutation: lineForStateMutation,
161
+ stateChange: stateChange
162
+ )
120
163
}
121
164
122
- public func expectStateToHaveChanged( _ expectedMutation: @escaping ( inout StateType ) -> Void = { _ in } ) -> Receive {
123
- . init( isExpectedAction: isExpectedAction, file: file, line: line, stateChange: { state in
165
+ public func expectStateToHaveChanged(
166
+ fileForStateMutation: StaticString = #file,
167
+ lineForStateMutation: UInt = #line,
168
+ _ expectedMutation: @escaping ( inout StateType ) -> Void = { _ in }
169
+ ) -> Receive {
170
+ Receive (
171
+ isExpectedAction: isExpectedAction,
172
+ file: file,
173
+ fileForStateMutation: fileForStateMutation,
174
+ line: line,
175
+ lineForStateMutation: lineForStateMutation
176
+ ) { state in
124
177
self . stateChange ( & state)
125
178
expectedMutation ( & state)
126
- } )
179
+ }
127
180
}
128
181
}
129
182
@@ -142,18 +195,22 @@ public enum Step<ActionType, StateType>: StepProtocol {
142
195
case send(
143
196
action: @autoclosure ( ) -> ActionType ,
144
197
file: StaticString = #file,
198
+ fileForStateMutation: StaticString = #file,
145
199
line: UInt = #line,
200
+ lineForStateMutation: UInt = #line,
146
201
stateChange: ( inout StateType ) -> Void = { _ in }
147
202
)
148
203
case receive(
149
204
isExpectedAction: ( ActionType ) -> Bool ,
150
205
file: StaticString = #file,
206
+ fileForStateMutation: StaticString = #file,
151
207
line: UInt = #line,
208
+ lineForStateMutation: UInt = #line,
152
209
stateChange: ( inout StateType ) -> Void = { _ in }
153
210
)
154
211
case sideEffectResult(
155
- do: ( ) -> Void
156
- )
212
+ do: ( ) -> Void
213
+ )
157
214
158
215
public var asStep : Step < ActionType , StateType > {
159
216
self
@@ -264,7 +321,7 @@ extension XCTestCase {
264
321
var expected = state
265
322
266
323
switch outerStep {
267
- case let . send( action, file, line , stateChange ) : //action, file, line , stateChange):
324
+ case let . send( action, file, fileForStateMutation , line , lineForStateMutation , stateChange) :
268
325
if !middlewareResponses. isEmpty {
269
326
XCTFail ( """
270
327
Action sent before handling \( middlewareResponses. count) pending effect(s):
@@ -283,8 +340,15 @@ extension XCTestCase {
283
340
afterReducer. reducerIsDone ( )
284
341
285
342
stateChange ( & expected)
286
- ensureStateMutation ( equating: stateEquating, statusQuo: state, expected: expected, step: outerStep, file: file, line: line)
287
- case let . receive( action, file, line, stateChange) : //action, file, line, stateChange):
343
+ ensureStateMutation (
344
+ equating: stateEquating,
345
+ statusQuo: state,
346
+ expected: expected,
347
+ step: outerStep,
348
+ file: fileForStateMutation,
349
+ line: lineForStateMutation
350
+ )
351
+ case let . receive( action, file, fileForStateMutation, line, lineForStateMutation, stateChange) : //action, file, line, stateChange):
288
352
if middlewareResponses. isEmpty {
289
353
_ = XCTWaiter . wait ( for: [ gotAction] , timeout: 0.2 )
290
354
}
@@ -305,7 +369,14 @@ extension XCTestCase {
305
369
afterReducer. reducerIsDone ( )
306
370
307
371
stateChange ( & expected)
308
- ensureStateMutation ( equating: stateEquating, statusQuo: state, expected: expected, step: outerStep, file: file, line: line)
372
+ ensureStateMutation (
373
+ equating: stateEquating,
374
+ statusQuo: state,
375
+ expected: expected,
376
+ step: outerStep,
377
+ file: fileForStateMutation,
378
+ line: lineForStateMutation
379
+ )
309
380
case let . sideEffectResult( execute) :
310
381
execute ( )
311
382
}
0 commit comments