Skip to content

Commit

Permalink
Update testScrollViewDidEndDragging tests to match `testScrollViewD…
Browse files Browse the repository at this point in the history
…idEndDecelerating `
  • Loading branch information
serluca committed Dec 12, 2016
1 parent e42c94d commit 742cc88
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions Tests/RxCocoaTests/UIScrollView+RxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,29 @@ extension UIScrollViewTests {
}

func testScrollViewDidEndDragging() {
let scheduler = TestScheduler(initialClock: 0)
let results = scheduler.createObserver(Bool.self)
var completed = false

autoreleasepool {
let scrollView = UIScrollView()
var results: [Bool] = []

_ = scrollView.rx.didEndDragging.subscribe(onNext: {
results.append($0)
}, onCompleted: {
completed = true
})

let o = scheduler.createHotObservable([
next(250, false),
next(300, true),
])
XCTAssertTrue(results.isEmpty)

let subscription: Disposable! = scrollView.rx.didEndDragging.subscribe(results)
scrollView.delegate!.scrollViewDidEndDragging!(scrollView, willDecelerate: false)
scrollView.delegate!.scrollViewDidEndDragging!(scrollView, willDecelerate: true)

_ = scheduler.start {
o.do(onNext: {
scrollView.delegate!.scrollViewDidEndDragging!(scrollView, willDecelerate: $0)
}, onDispose: {
subscription.dispose()
})
}
XCTAssertEqual(results, [false, true])
}

XCTAssertTrue(completed)

}
XCTAssertEqual(results.events, [
next(250, false),
next(300, true)
])
}

func testScrollViewContentOffset() {
var completed = false
Expand Down

0 comments on commit 742cc88

Please sign in to comment.