Skip to content

Commit 1fd043f

Browse files
authored
Merge pull request #9 from SwiftRex/MiddlewareIO
Update SwiftRex to use Middleware IO
2 parents 0868734 + 616997a commit 1fd043f

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let package = Package(
1717
],
1818
dependencies: [
1919
.package(name: "SnapshotTesting", url: "https://github.com/pointfreeco/swift-snapshot-testing.git", .upToNextMajor(from: "1.8.2")),
20-
.package(name: "SwiftRex", url: "https://github.com/SwiftRex/SwiftRex.git", .upToNextMajor(from: "0.8.6"))
20+
.package(name: "SwiftRex", url: "https://github.com/SwiftRex/SwiftRex.git", .upToNextMajor(from: "0.8.8"))
2121
],
2222
targets: [
2323
.target(

Sources/TestingExtensions/UseCaseTests.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import Combine
1111
import CombineRex
1212
import Foundation
13-
import SwiftRex
13+
@testable import SwiftRex
1414
import XCTest
1515

1616
#if swift(>=5.4)
@@ -219,7 +219,7 @@ public enum Step<ActionType, StateType>: StepProtocol {
219219

220220
extension XCTestCase {
221221
#if swift(>=5.4)
222-
public func assert<M: Middleware>(
222+
public func assert<M: MiddlewareProtocol>(
223223
initialValue: M.StateType,
224224
reducer: Reducer<M.InputActionType, M.StateType>,
225225
middleware: M,
@@ -238,7 +238,7 @@ extension XCTestCase {
238238
)
239239
}
240240

241-
public func assert<M: Middleware>(
241+
public func assert<M: MiddlewareProtocol>(
242242
initialValue: M.StateType,
243243
reducer: Reducer<M.InputActionType, M.StateType>,
244244
middleware: M,
@@ -259,7 +259,7 @@ extension XCTestCase {
259259
}
260260
#endif
261261

262-
public func assert<M: Middleware>(
262+
public func assert<M: MiddlewareProtocol>(
263263
initialValue: M.StateType,
264264
reducer: Reducer<M.InputActionType, M.StateType>,
265265
middleware: M,
@@ -278,7 +278,7 @@ extension XCTestCase {
278278
)
279279
}
280280

281-
public func assert<M: Middleware>(
281+
public func assert<M: MiddlewareProtocol>(
282282
initialValue: M.StateType,
283283
reducer: Reducer<M.InputActionType, M.StateType>,
284284
middleware: M,
@@ -298,7 +298,7 @@ extension XCTestCase {
298298
)
299299
}
300300

301-
private func assert<M: Middleware>(
301+
private func assert<M: MiddlewareProtocol>(
302302
initialValue: M.StateType,
303303
reducer: Reducer<M.InputActionType, M.StateType>,
304304
middleware: M,
@@ -329,16 +329,15 @@ extension XCTestCase {
329329
""", file: file, line: line)
330330
}
331331

332-
var afterReducer: AfterReducer = .doNothing()
333332
let action = action()
334-
middleware.handle(
333+
let io = middleware.handle(
335334
action: action,
336335
from: .init(file: "\(file)", function: "", line: line, info: nil),
337-
afterReducer: &afterReducer
336+
state: { state }
338337
)
339338
reducer.reduce(action, &state)
340339
#if DEBUG
341-
afterReducer.performBlock()
340+
io.runIO(anyActionHandler)
342341
#else
343342
XCTFail("Please run the tests in DEBUG otherwise after reducer won't be called")
344343
#endif
@@ -363,15 +362,14 @@ extension XCTestCase {
363362
let first = middlewareResponses.removeFirst()
364363
XCTAssertTrue(action(first), file: file, line: line)
365364

366-
var afterReducer: AfterReducer = .doNothing()
367-
middleware.handle(
365+
let io = middleware.handle(
368366
action: first,
369367
from: .init(file: "\(file)", function: "", line: line, info: nil),
370-
afterReducer: &afterReducer
368+
state: { state }
371369
)
372370
reducer.reduce(first, &state)
373371
#if DEBUG
374-
afterReducer.performBlock()
372+
io.runIO(anyActionHandler)
375373
#else
376374
XCTFail("Please run the tests in DEBUG otherwise after reducer won't be called")
377375
#endif

0 commit comments

Comments
 (0)