mirror of
https://github.com/samsonjs/AsyncMonitor.git
synced 2026-03-25 08:25:47 +00:00
Instead of having a values method that observes and monitors, break out a values method that returns an AsyncStream and then a monitorValues method that calls values(for: keyPath).monitor. That method is kind of superfluous, not sure if it's good to keep it or not.
26 lines
656 B
Swift
26 lines
656 B
Swift
@testable import AsyncMonitor
|
|
import Testing
|
|
|
|
@MainActor class AnyAsyncCancellableTests {
|
|
var subject: AnyAsyncCancellable!
|
|
|
|
@Test func cancelsWhenReleased() {
|
|
let cancellable = TestCancellable()
|
|
subject = AnyAsyncCancellable(cancellable: cancellable)
|
|
#expect(!cancellable.isCancelled)
|
|
|
|
subject = nil
|
|
|
|
#expect(cancellable.isCancelled)
|
|
}
|
|
|
|
@Test func cancelsWhenCancelled() {
|
|
let cancellable = TestCancellable()
|
|
subject = AnyAsyncCancellable(cancellable: cancellable)
|
|
#expect(!cancellable.isCancelled)
|
|
|
|
subject.cancel()
|
|
|
|
#expect(cancellable.isCancelled)
|
|
}
|
|
}
|