From 1a630a6927228d87a9995c78c1b74d3ac9cd0df8 Mon Sep 17 00:00:00 2001 From: freak4pc Date: Thu, 23 Aug 2018 13:07:15 +0300 Subject: [PATCH] Add Observable+Bind tests --- Tests/RxCocoaTests/Observable+BindTests.swift | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Tests/RxCocoaTests/Observable+BindTests.swift b/Tests/RxCocoaTests/Observable+BindTests.swift index 1439d9a59..8446d2a89 100644 --- a/Tests/RxCocoaTests/Observable+BindTests.swift +++ b/Tests/RxCocoaTests/Observable+BindTests.swift @@ -30,7 +30,32 @@ extension ObservableBindTest { XCTAssertEqual(events, [ .next(1), .completed() - ]) + ]) + } + + func testBindToObservers() { + var events1: [Recorded>] = [] + var events2: [Recorded>] = [] + + let observer1: AnyObserver = AnyObserver { event in + events1.append(Recorded(time: 0, value: event)) + } + + let observer2: AnyObserver = AnyObserver { event in + events2.append(Recorded(time: 0, value: event)) + } + + _ = Observable.just(1).bind(to: observer1, observer2) + + XCTAssertEqual(events1, [ + .next(1), + .completed() + ]) + + XCTAssertEqual(events2, [ + .next(1), + .completed() + ]) } func testBindToOptionalObserver() { @@ -49,6 +74,31 @@ extension ObservableBindTest { } } + func testBindToOptionalObservers() { + var events1: [Recorded>] = [] + var events2: [Recorded>] = [] + + let observer1: AnyObserver = AnyObserver { event in + events1.append(Recorded(time: 0, value: event)) + } + + let observer2: AnyObserver = AnyObserver { event in + events2.append(Recorded(time: 0, value: event)) + } + + _ = (Observable.just(1) as Observable).bind(to: observer1, observer2) + + XCTAssertEqual(events1, [ + .next(1), + .completed() + ]) + + XCTAssertEqual(events2, [ + .next(1), + .completed() + ]) + } + func testBindToOptionalObserverNoAmbiguity() { var events: [Recorded>] = []