@@ -80,7 +80,7 @@ final class StoreTests: XCTestCase {
8080 let childStore = parentStore. scope ( state: String . init)
8181
8282 var values : [ String ] = [ ]
83- childStore. $state . producer
83+ childStore. producer
8484 . startWithValues { values. append ( $0) }
8585
8686 XCTAssertEqual ( values, [ " 0 " ] )
@@ -101,7 +101,7 @@ final class StoreTests: XCTestCase {
101101 let childViewStore = ViewStore ( childStore)
102102
103103 var values : [ Int ] = [ ]
104- parentStore. $state . producer
104+ parentStore. producer
105105 . startWithValues { values. append ( $0) }
106106
107107 XCTAssertEqual ( values, [ 0 ] )
@@ -123,7 +123,7 @@ final class StoreTests: XCTestCase {
123123 parentStore
124124 . producerScope ( state: { $0. map { " \( $0) " } . skipRepeats ( ) } )
125125 . startWithValues { childStore in
126- childStore. $state . producer
126+ childStore. producer
127127 . startWithValues { outputs. append ( $0) }
128128 }
129129
@@ -282,7 +282,7 @@ final class StoreTests: XCTestCase {
282282
283283 parentStore
284284 . producerScope { $0. skipRepeats ( ) }
285- . startWithValues { outputs. append ( $0. $ state. value ) }
285+ . startWithValues { outputs. append ( $0. state) }
286286
287287 XCTAssertEqual ( outputs, [ 0 ] )
288288
@@ -451,73 +451,73 @@ final class StoreTests: XCTestCase {
451451 }
452452
453453// This test commented out as it falls foul of ReactiveSwift's
454- // `MutableProperty ` not allowing nested modifications 😢
455-
456- // func testBufferedActionProcessing () {
457- // struct ChildState: Equatable {
458- // var count: Int?
459- // }
460- //
461- // let childReducer = Reducer<ChildState, Int?, Void> { state, action, _ in
462- // state.count = action
463- // return .none
464- // }
465- //
466- // struct ParentState: Equatable {
467- // var count: Int?
468- // var child: ChildState?
469- // }
470- //
471- // enum ParentAction: Equatable {
472- // case button
473- // case child(Int?)
474- // }
475- //
476- // var handledActions: [ParentAction] = []
477- // let parentReducer = Reducer.combine([
478- // childReducer
479- // .optional()
480- // .pullback(
481- // state: \.child,
482- // action: /ParentAction.child,
483- // environment: {}
484- // ),
485- // Reducer<ParentState, ParentAction, Void> { state, action, _ in
486- // handledActions.append(action)
487- //
488- // switch action {
489- // case .button:
490- // state.child = .init(count: nil)
491- // return .none
492- //
493- // case .child(let childCount):
494- // state.count = childCount
495- // return .none
496- // }
497- // },
498- // ])
499- //
500- // let parentStore = Store(
501- // initialState: .init(),
502- // reducer: parentReducer,
503- // environment: ()
504- // )
505- //
506- // parentStore
507- // .scope(
508- // state: \.child,
509- // action: ParentAction.child
510- // )
511- // .ifLet { childStore in
512- // ViewStore(childStore).send(2)
513- // }
514- //
515- // XCTAssertEqual(handledActions, [])
516- //
517- // parentStore.send(.button)
518- // XCTAssertEqual(handledActions, [
519- // .button,
520- // .child(2)
521- // ])
522- // }
454+ // `Signal ` not allowing nested sends 😢
455+
456+ func disabled_testBufferedActionProcessing ( ) {
457+ struct ChildState : Equatable {
458+ var count : Int ?
459+ }
460+
461+ let childReducer = Reducer < ChildState , Int ? , Void > { state, action, _ in
462+ state. count = action
463+ return . none
464+ }
465+
466+ struct ParentState : Equatable {
467+ var count : Int ?
468+ var child : ChildState ?
469+ }
470+
471+ enum ParentAction : Equatable {
472+ case button
473+ case child( Int ? )
474+ }
475+
476+ var handledActions : [ ParentAction ] = [ ]
477+ let parentReducer = Reducer . combine ( [
478+ childReducer
479+ . optional ( )
480+ . pullback (
481+ state: \. child,
482+ action: / ParentAction. child,
483+ environment: { }
484+ ) ,
485+ Reducer< ParentState, ParentAction, Void> { state, action, _ in
486+ handledActions. append ( action)
487+
488+ switch action {
489+ case . button:
490+ state. child = . init( count: nil )
491+ return . none
492+
493+ case . child( let childCount) :
494+ state. count = childCount
495+ return . none
496+ }
497+ } ,
498+ ] )
499+
500+ let parentStore = Store (
501+ initialState: . init( ) ,
502+ reducer: parentReducer,
503+ environment: ( )
504+ )
505+
506+ parentStore
507+ . scope (
508+ state: \. child,
509+ action: ParentAction . child
510+ )
511+ . ifLet { childStore in
512+ ViewStore ( childStore) . send ( 2 )
513+ }
514+
515+ XCTAssertEqual ( handledActions, [ ] )
516+
517+ parentStore. send ( . button)
518+ XCTAssertEqual ( handledActions, [
519+ . button,
520+ . child( 2 )
521+ ] )
522+ }
523523}
0 commit comments