A ViewModel has an input (an observer) which is bound to tap
event of UIButton
in UIViewController
. This observer is of type AnyObserver<Void>
.
In my unit test, this is what I'm expecting:
let correctValues: [Recorded<Event<Void>>] = Recorded.events(
.next(0, ()),
.completed(0)
)
My test observer definition is:
private var voidEventsObserver: TestableObserver<Void>!
let scheduler = TestScheduler(initialClock: 0)
voidEventsObserver = scheduler.createObserver(Void.self)
Assert statement:
XCTAssertEqual(voidEventsObserver.events, correctValues)
I'm getting following error:
Expression type '()' is ambiguous without more context
In Rx, Void
events are normal and to properly test ViewModel, one needs to compare them. e.g. .next(0, ())
, .completed(0)
etc. Void
is not Equatable
and it doesn't make sense to make it Equatable
. However, I need to assert if the event is .next
or .error
or .completed
. How do I assert that part?