Implemented
This commit is contained in:
Родитель
06d37ab702
Коммит
a2ce0df087
|
@ -74,6 +74,14 @@ extension SearchPresenter: SearchPeopleModuleOutput, SearchTopicsModuleOutput {
|
|||
func didSelectHashtag(_ hashtag: Hashtag) {
|
||||
view.search(hashtag: hashtag)
|
||||
}
|
||||
|
||||
func didStartLoadingSearchTopicsQuery() {
|
||||
view.setTopicsLayoutFlipEnabled(false)
|
||||
}
|
||||
|
||||
func didLoadSearchTopicsQuery() {
|
||||
view.setTopicsLayoutFlipEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
extension SearchPresenter: SearchModuleInput {
|
||||
|
|
|
@ -138,6 +138,10 @@ extension SearchViewController: SearchViewInput {
|
|||
func search(hashtag: Hashtag) {
|
||||
searchSelectedText(hashtag)
|
||||
}
|
||||
|
||||
func setTopicsLayoutFlipEnabled(_ isEnabled: Bool) {
|
||||
feedLayoutButton.isEnabled = isEnabled
|
||||
}
|
||||
}
|
||||
|
||||
extension SearchViewController: UISearchBarDelegate {
|
||||
|
|
|
@ -16,4 +16,6 @@ protocol SearchViewInput: class {
|
|||
func setLayoutAsset(_ asset: Asset)
|
||||
|
||||
func search(hashtag: Hashtag)
|
||||
|
||||
func setTopicsLayoutFlipEnabled(_ isEnabled: Bool)
|
||||
}
|
||||
|
|
|
@ -9,4 +9,8 @@ protocol SearchTopicsModuleOutput: class {
|
|||
func didFailToLoadSearchQuery(_ error: Error)
|
||||
|
||||
func didSelectHashtag(_ hashtag: Hashtag)
|
||||
|
||||
func didStartLoadingSearchTopicsQuery()
|
||||
|
||||
func didLoadSearchTopicsQuery()
|
||||
}
|
||||
|
|
|
@ -63,8 +63,13 @@ extension SearchTopicsPresenter: FeedModuleOutput {
|
|||
return true
|
||||
}
|
||||
|
||||
func didUpdateFeed() {
|
||||
func didStartRefreshingData() {
|
||||
moduleOutput?.didStartLoadingSearchTopicsQuery()
|
||||
}
|
||||
|
||||
func didFinishRefreshingData(_ error: Error?) {
|
||||
view.setIsEmpty(feedModule.isEmpty)
|
||||
moduleOutput?.didLoadSearchTopicsQuery()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,14 +47,24 @@ class MockSearchView: SearchViewInput {
|
|||
setLayoutAssetReceivedAsset = asset
|
||||
}
|
||||
|
||||
// MARK: - search
|
||||
//MARK: - search
|
||||
|
||||
var searchHashtagCalled = false
|
||||
var searchHashtagInputHashtag: Hashtag?
|
||||
|
||||
var searchHashtagReceivedHashtag: Hashtag?
|
||||
|
||||
func search(hashtag: Hashtag) {
|
||||
searchHashtagCalled = true
|
||||
searchHashtagInputHashtag = hashtag
|
||||
searchHashtagReceivedHashtag = hashtag
|
||||
}
|
||||
|
||||
//MARK: - setTopicsLayoutFlipEnabled
|
||||
|
||||
var setTopicsLayoutFlipEnabledCalled = false
|
||||
var setTopicsLayoutFlipEnabledReceivedIsEnabled: Bool?
|
||||
|
||||
func setTopicsLayoutFlipEnabled(_ isEnabled: Bool) {
|
||||
setTopicsLayoutFlipEnabledCalled = true
|
||||
setTopicsLayoutFlipEnabledReceivedIsEnabled = isEnabled
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ class SearchPresenterTests: XCTestCase {
|
|||
let hashtag = UUID().uuidString
|
||||
sut.didSelectHashtag(hashtag)
|
||||
XCTAssertTrue(view.searchHashtagCalled)
|
||||
XCTAssertEqual(view.searchHashtagInputHashtag, hashtag)
|
||||
XCTAssertEqual(view.searchHashtagReceivedHashtag, hashtag)
|
||||
}
|
||||
|
||||
private func makePeopleTab() -> SearchTabInfo {
|
||||
|
@ -180,7 +180,7 @@ class SearchPresenterTests: XCTestCase {
|
|||
|
||||
XCTAssertEqual(view.setupInitialStateReceivedTab, topicsTab)
|
||||
XCTAssertTrue(view.searchHashtagCalled)
|
||||
XCTAssertEqual(view.searchHashtagInputHashtag, "1")
|
||||
XCTAssertEqual(view.searchHashtagReceivedHashtag, "1")
|
||||
}
|
||||
|
||||
func testSearchHashtagAfterViewIsReadyAndPeopleTabSelected() {
|
||||
|
@ -200,6 +200,18 @@ class SearchPresenterTests: XCTestCase {
|
|||
XCTAssertEqual(view.switchTabsToFromReceivedArguments?.tab, topicsTab)
|
||||
|
||||
XCTAssertTrue(view.searchHashtagCalled)
|
||||
XCTAssertEqual(view.searchHashtagInputHashtag, "1")
|
||||
XCTAssertEqual(view.searchHashtagReceivedHashtag, "1")
|
||||
}
|
||||
|
||||
func testStartLoadingTopicsQuery() {
|
||||
sut.didStartLoadingSearchTopicsQuery()
|
||||
XCTAssertTrue(view.setTopicsLayoutFlipEnabledCalled)
|
||||
XCTAssertEqual(view.setTopicsLayoutFlipEnabledReceivedIsEnabled, false)
|
||||
}
|
||||
|
||||
func testFinishLoadingTopicsQuery() {
|
||||
sut.didLoadSearchTopicsQuery()
|
||||
XCTAssertTrue(view.setTopicsLayoutFlipEnabledCalled)
|
||||
XCTAssertEqual(view.setTopicsLayoutFlipEnabledReceivedIsEnabled, true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,4 +26,20 @@ class MockSearchTopicsModuleOutput: SearchTopicsModuleOutput {
|
|||
didSelectHashtagCalled = true
|
||||
didSelectHashtagReceivedHashtag = hashtag
|
||||
}
|
||||
|
||||
//MARK: - didStartLoadingSearchTopicsQuery
|
||||
|
||||
var didStartLoadingSearchTopicsQueryCalled = false
|
||||
|
||||
func didStartLoadingSearchTopicsQuery() {
|
||||
didStartLoadingSearchTopicsQueryCalled = true
|
||||
}
|
||||
|
||||
//MARK: - didLoadSearchTopicsQuery
|
||||
|
||||
var didLoadSearchTopicsQueryCalled = false
|
||||
|
||||
func didLoadSearchTopicsQuery() {
|
||||
didLoadSearchTopicsQueryCalled = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class SearchTopicsPresenterTests: XCTestCase {
|
|||
XCTAssertEqual(view.setupInitialStateWithReceivedFeedViewController, feedViewController)
|
||||
}
|
||||
|
||||
func testThatItSetsViewIsEmptyWhenFeedIsUpdated() {
|
||||
func testThatItSetsViewIsEmptyWhenFeedFinishesRefreshing() {
|
||||
testThatItSetsViewIsEmptyWhenFeedIsUpdated(feedIsEmpty: true, isViewExpectedToBeEmpty: true)
|
||||
|
||||
testThatItSetsViewIsEmptyWhenFeedIsUpdated(feedIsEmpty: false, isViewExpectedToBeEmpty: false)
|
||||
|
@ -77,7 +77,7 @@ class SearchTopicsPresenterTests: XCTestCase {
|
|||
feedModule.isEmpty = feedIsEmpty
|
||||
|
||||
// when
|
||||
sut.didUpdateFeed()
|
||||
sut.didFinishRefreshingData(APIError.unknown)
|
||||
|
||||
// then
|
||||
XCTAssertTrue(view.setIsEmptyCalled)
|
||||
|
|
Загрузка…
Ссылка в новой задаче