File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
Tests/ComposableArchitectureTests Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -275,9 +275,21 @@ final class TestStoreTests: XCTestCase {
275275 self . date = now
276276 }
277277 }
278- func reduce( into state: inout State , action: Void ) -> EffectTask < Void > {
279- state. count += 1
280- return . none
278+ enum Action : Equatable {
279+ case tap
280+ case response( Int )
281+ }
282+ @Dependency ( \. date. now) var now : Date
283+ func reduce( into state: inout State , action: Action ) -> EffectTask < Action > {
284+ switch action {
285+ case . tap:
286+ state. count += 1
287+ return . task { . response( 42 ) }
288+ case let . response( number) :
289+ state. count = number
290+ state. date = now
291+ return . none
292+ }
281293 }
282294 }
283295
@@ -288,10 +300,15 @@ final class TestStoreTests: XCTestCase {
288300 $0. date = . constant( Date ( timeIntervalSince1970: 1_234_567_890 ) )
289301 }
290302
291- await store. send ( ( ) ) {
303+ await store. send ( . tap ) {
292304 @Dependency ( \. date. now) var now : Date
293305 $0. count = 1
294306 $0. date = now
295307 }
308+ await store. receive ( . response( 42 ) ) {
309+ @Dependency ( \. date. now) var now : Date
310+ $0. count = 42
311+ $0. date = now
312+ }
296313 }
297314}
You can’t perform that action at this time.
0 commit comments