Skip to content

Commit 2b52ad8

Browse files
committed
Add test
1 parent ebd37bd commit 2b52ad8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Tests/ComposableArchitectureTests/EffectCancellationTests.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)