mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
* Infrastructure: Address concurrency warnings in tests * wip --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com>
43 lines
1.0 KiB
Swift
43 lines
1.0 KiB
Swift
#if DEBUG
|
|
import XCTest
|
|
|
|
@testable import ComposableArchitecture
|
|
|
|
final class BindingLocalTests: BaseTCATestCase {
|
|
@MainActor
|
|
public func testBindingLocalIsActive() {
|
|
XCTAssertFalse(BindingLocal.isActive)
|
|
|
|
struct MyReducer: Reducer {
|
|
struct State: Equatable {
|
|
var text = ""
|
|
}
|
|
|
|
enum Action: Equatable {
|
|
case textChanged(String)
|
|
}
|
|
|
|
var body: some Reducer<State, Action> {
|
|
Reduce(internal: { state, action in
|
|
switch action {
|
|
case let .textChanged(text):
|
|
state.text = text
|
|
return .none
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
let store = Store(initialState: MyReducer.State()) { 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
|