mirror of
https://github.com/ReactiveX/RxSwift.git
synced 2024-10-05 06:27:29 +03:00
Added tests for selectedScopeButtonIndex
This commit is contained in:
parent
23a3743a23
commit
4ebf810993
@ -44,4 +44,31 @@ class UISearchBarTests : RxTest {
|
||||
_ = Observable.just("value").bindTo(searchBar.rx_text)
|
||||
XCTAssertEqual(searchBar.text, "value")
|
||||
}
|
||||
|
||||
func testSelectedScopeButtonIndex_changeEventWOrks() {
|
||||
let searchBar = UISearchBar(frame: CGRectMake(0, 0, 1, 1))
|
||||
searchBar.scopeButtonTitles = [ "One", "Two", "Three" ]
|
||||
|
||||
var latestSelectedScopeIndex: Int = -1
|
||||
|
||||
_ = searchBar.rx_selectedScopeButtonIndex.subscribeNext { index in
|
||||
latestSelectedScopeIndex = index
|
||||
}
|
||||
|
||||
XCTAssertEqual(latestSelectedScopeIndex, 0)
|
||||
|
||||
searchBar.selectedScopeButtonIndex = 1
|
||||
searchBar.delegate!.searchBar!(searchBar, selectedScopeButtonIndexDidChange: 1)
|
||||
|
||||
XCTAssertEqual(latestSelectedScopeIndex, 1)
|
||||
}
|
||||
|
||||
func testSelectedScopeButtonIndex_binding() {
|
||||
let searchBar = UISearchBar(frame: CGRectMake(0, 0, 1, 1))
|
||||
searchBar.scopeButtonTitles = [ "One", "Two", "Three" ]
|
||||
|
||||
XCTAssertNotEqual(searchBar.selectedScopeButtonIndex, 1)
|
||||
_ = Observable.just(1).bindTo(searchBar.rx_selectedScopeButtonIndex)
|
||||
XCTAssertEqual(searchBar.selectedScopeButtonIndex, 1)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user