CombineErgonomics Documentation

Extensions on XCTestCase

Methods

values(for:​drop​First:​expected​Number:​when​Executing​Closure:​)

func values<T, P: Publisher>(for publisher: P,
                                 dropFirst: Int = 1,
                                 expectedNumber: Int = 1,
                                 whenExecutingClosure closure: () -> Void) -> [T]
    where P.Output == T, P.Failure == Never  

Helper method for testing the values of Publisher in response to other code being executed.

Parameters

publisher P

A non-failable publisher

drop​First Int

Value to pass to publisher.dropFirst before observing. This defaults to 1 as a convenience, in order to ignore the initial value that is sent when observing a Publisher.

expected​Number Int

The number of .next events that should be received from publisher after executing closure.

closure () -> Void

The method will execute this closure and then wait for expectedNumber of .next events to be received from the publisher before returning

Returns

The collected values from the publisher.

reject(_:​drop​First:​when​Executing​Closure:​)

func reject<T, P: Publisher>(_ publisher: P, dropFirst: Int = 1, whenExecutingClosure closure: () -> Void)
    where P.Output == T, P.Failure == Never  

Helper method for verifying that Publisher does not send any .next events when executing the given closure.

Parameters

publisher P

A non-failable publisher.

drop​First Int

Value to pass to publisher.dropFirst before observing. This defaults to 1 as a convenience, in order to ignore the initial value that is sent when observing a Publisher.

closure () -> Void

The method will execute this closure and then wait to verify that signal does not send any .next events afterward.

wait​Until​False(_:​)

func waitUntilFalse<P: Publisher>(_ publisher: P)
    where P.Output == Bool, P.Failure == Never  

Waits for the given Bool publisher to send a value of false before proceeding.

time​Delayed​Future(result:​on:​after:​)

func timeDelayedFuture<O, E, S>(result: Result<O, E>,
                                    on scheduler: S,
                                    after delay: S.SchedulerTimeType.Stride) -> Future<O, E>
    where E: Error, S: Scheduler  

Helper method to return a future that completes after a certain amount of time

Parameters

result Result<O, E>

the Result for the future to complete with

scheduler S

scheduler on which to return the result on

delay S.​Scheduler​Time​Type.​Stride

time interval after which the future should complete

Returns

a Future that completes in a set amount of time on a given scheduler.

time​Delayed​Future(result:​after:​)

func timeDelayedFuture<O, E>(result: Result<O, E>, after delay: TimeInterval) -> Future<O, E>
    where E: Error  

Helper method to return a future that completes after a certain amount of time

Parameters

result Result<O, E>

the Result for the future to complete with

delay Time​Interval

time interval (in seconds) after which the future should complete

Returns

a Future that completes in a set amount of time on a DispatchQueue.global().