-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SSDK-541] Add searchbox validation, change Demo to searchbox (#164)
### Description - Fixes [SSDK-541](https://mapbox.atlassian.net/browse/SSDK-541) - Start adding search-box API validation - Increase test coverage for search-box API usage ### Checklist - [x] Update `CHANGELOG` [SSDK-541]: https://mapbox.atlassian.net/browse/SSDK-541
- Loading branch information
Showing
35 changed files
with
2,572 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ extension ApiType { | |
return .geocoding | ||
case .SBS: | ||
return .SBS | ||
case .searchBox: | ||
return .searchBox | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...boxSearchIntegrationTests/search-box/SearchBox_CategorySearchEngineIntegrationTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import CoreLocation | ||
@testable import MapboxSearch | ||
import XCTest | ||
|
||
final class SearchBox_CategorySearchEngineIntegrationTests: MockServerIntegrationTestCase<SearchBoxMockResponse> { | ||
private var searchEngine: CategorySearchEngine! | ||
|
||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
|
||
let apiType = try XCTUnwrap(Mock.coreApiType.toSDKType()) | ||
searchEngine = CategorySearchEngine( | ||
accessToken: "access-token", | ||
serviceProvider: LocalhostMockServiceProvider.shared, | ||
apiType: apiType | ||
) | ||
} | ||
|
||
func testCategorySearch() throws { | ||
try server.setResponse(.categoryCafe) | ||
|
||
let expectation = XCTestExpectation(description: "Expecting results") | ||
searchEngine.search(categoryName: "cafe") { result in | ||
switch result { | ||
case .success(let searchResults): | ||
XCTAssertFalse(searchResults.isEmpty) | ||
expectation.fulfill() | ||
case .failure: | ||
XCTFail("Error not expected") | ||
} | ||
expectation.fulfill() | ||
} | ||
wait(for: [expectation], timeout: 10) | ||
} | ||
|
||
func testCategorySearchFailed() throws { | ||
try server.setResponse(.categoryCafe, statusCode: 500) | ||
|
||
let expectation = XCTestExpectation(description: "Expecting failure") | ||
searchEngine.search(categoryName: "cafe") { result in | ||
switch result { | ||
case .success: | ||
XCTFail("Not expected") | ||
case .failure(let searchError): | ||
if case .generic(let code, _, _) = searchError { | ||
XCTAssert(code == 500) | ||
} else { | ||
XCTFail("Not expected") | ||
} | ||
} | ||
expectation.fulfill() | ||
} | ||
wait(for: [expectation], timeout: 10) | ||
} | ||
} |
Oops, something went wrong.