Skip to content

Commit

Permalink
Add Observable+Bind tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freak4pc committed Apr 8, 2019
1 parent d69344e commit 1a630a6
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion Tests/RxCocoaTests/Observable+BindTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,32 @@ extension ObservableBindTest {
XCTAssertEqual(events, [
.next(1),
.completed()
])
])
}

func testBindToObservers() {
var events1: [Recorded<Event<Int>>] = []
var events2: [Recorded<Event<Int>>] = []

let observer1: AnyObserver<Int> = AnyObserver { event in
events1.append(Recorded(time: 0, value: event))
}

let observer2: AnyObserver<Int> = 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() {
Expand All @@ -49,6 +74,31 @@ extension ObservableBindTest {
}
}

func testBindToOptionalObservers() {
var events1: [Recorded<Event<Int?>>] = []
var events2: [Recorded<Event<Int?>>] = []

let observer1: AnyObserver<Int?> = AnyObserver { event in
events1.append(Recorded(time: 0, value: event))
}

let observer2: AnyObserver<Int?> = AnyObserver { event in
events2.append(Recorded(time: 0, value: event))
}

_ = (Observable.just(1) as Observable<Int>).bind(to: observer1, observer2)

XCTAssertEqual(events1, [
.next(1),
.completed()
])

XCTAssertEqual(events2, [
.next(1),
.completed()
])
}

func testBindToOptionalObserverNoAmbiguity() {
var events: [Recorded<Event<Int?>>] = []

Expand Down

0 comments on commit 1a630a6

Please sign in to comment.