@@ -288,17 +288,27 @@ extension PublisherExpectations {
288
288
}
289
289
290
290
extension Recorder {
291
- /// Returns a publisher expectation which waits for the timeout to expire.
291
+ /// Returns a publisher expectation which waits for the timeout to expire,
292
+ /// or the recorded publisher to complete.
292
293
///
293
- /// When waiting for this expectation, the publisher error is thrown if the
294
- /// publisher fails before expiration .
294
+ /// When waiting for this expectation, the publisher error is thrown if
295
+ /// the publisher fails before the expectation has expired .
295
296
///
296
297
/// Otherwise, an array of all elements published before the expectation
297
298
/// has expired is returned.
298
299
///
300
+ /// Unlike other expectations, `availableElements` does not make a test fail
301
+ /// on timeout expiration. It just returns the elements published so far.
302
+ ///
299
303
/// For example:
300
304
///
301
- /// // TODO
305
+ /// // SUCCESS: no timeout, no error
306
+ /// func testTimerPublishesIncreasingDates() throws {
307
+ /// let publisher = Timer.publish(every: 0.01, on: .main, in: .common).autoconnect()
308
+ /// let recorder = publisher.record()
309
+ /// let dates = try wait(for: recorder.availableElements, timeout: ...)
310
+ /// XCTAssertEqual(dates.sorted(), dates)
311
+ /// }
302
312
public var availableElements : PublisherExpectations . AvailableElements < Input , Failure > {
303
313
PublisherExpectations . AvailableElements ( recorder: self )
304
314
}
0 commit comments