forked from pointfreeco/swift-composable-architecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…reeco#1879) * `IfLetStore`: ignore view store binding writes to `nil` state * swift-format * wip * add test for filter --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com>
- Loading branch information
1 parent
1a168e2
commit 98af2ad
Showing
5 changed files
with
120 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#if DEBUG | ||
import XCTest | ||
|
||
@testable import ComposableArchitecture | ||
|
||
@MainActor | ||
final class BindingLocalTests: XCTestCase { | ||
public func testBindingLocalIsActive() { | ||
XCTAssertFalse(BindingLocal.isActive) | ||
|
||
struct MyReducer: ReducerProtocol { | ||
struct State: Equatable { | ||
var text = "" | ||
} | ||
|
||
enum Action: Equatable { | ||
case textChanged(String) | ||
} | ||
|
||
func reduce(into state: inout State, action: Action) -> EffectTask<Action> { | ||
switch action { | ||
case let .textChanged(text): | ||
state.text = text | ||
return .none | ||
} | ||
} | ||
} | ||
|
||
let store = Store(initialState: MyReducer.State(), reducer: MyReducer()) | ||
let viewStore = ViewStore(store, observe: { $0 }) | ||
|
||
let binding = viewStore.binding(get: \.text) { text in | ||
XCTAssertTrue(BindingLocal.isActive) | ||
return .textChanged(text) | ||
} | ||
binding.wrappedValue = "Hello!" | ||
XCTAssertEqual(viewStore.text, "Hello!") | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters