mirror of
https://github.com/samsonjs/AsyncMonitor.git
synced 2026-03-25 08:25:47 +00:00
21 lines
588 B
Swift
21 lines
588 B
Swift
@testable import AsyncMonitor
|
|
import Foundation
|
|
import Testing
|
|
|
|
class AsyncKVOTests {
|
|
var subject: Progress? = Progress(totalUnitCount: 42)
|
|
var cancellable: (any AsyncCancellable)?
|
|
|
|
@Test func yieldsChanges() async throws {
|
|
let subject = try #require(subject)
|
|
var values = [Double]()
|
|
cancellable = subject.values(for: \.fractionCompleted) { progress in
|
|
values.append(progress)
|
|
}
|
|
for _ in 1...3 {
|
|
subject.completedUnitCount += 1
|
|
await Task.yield()
|
|
}
|
|
#expect(values.count == 3)
|
|
}
|
|
}
|