File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Tests/ComposableArchitectureTests Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -432,5 +432,37 @@ final class EffectCancellationTests: BaseTCATestCase {
432432 // structs in Swift have the same hash value.
433433 XCTAssertNotEqual ( id1. hashValue, id2. hashValue)
434434 }
435+
436+ func testCancellablePath( ) async throws {
437+ let navigationIDPath = dump ( NavigationIDPath ( path: [ NavigationID ( ) ] ) )
438+ let effect = withDependencies {
439+ $0. navigationIDPath = navigationIDPath
440+ } operation: {
441+ Effect
442+ . publisher {
443+ Just ( ( ) ) . delay ( for: . seconds( 1 ) , scheduler: DispatchQueue ( label: #function) )
444+ }
445+ . cancellable ( id: 1 )
446+ }
447+ await withThrowingTaskGroup ( of: Void . self) { taskGroup in
448+ taskGroup. addTask {
449+ await withDependencies {
450+ $0. navigationIDPath = NavigationIDPath ( path: [ NavigationID ( ) ] )
451+ } operation: {
452+ for await action in effect. actions {
453+ XCTFail ( )
454+ }
455+ }
456+ }
457+ taskGroup. addTask {
458+ try await withDependencies {
459+ $0. navigationIDPath = navigationIDPath
460+ } operation: {
461+ try await Task . sleep ( for: . seconds( 0.5 ) )
462+ Task . cancel ( id: 1 )
463+ }
464+ }
465+ }
466+ }
435467 }
436468#endif
You can’t perform that action at this time.
0 commit comments