-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SSDK-399] Add Discover.Options(country, proximity, origin) (#167)
### Description **Ticket**: [SSDK-399](https://mapbox.atlassian.net/browse/SSDK-399) - Add Country.default: Self? to auto-detect the current device region and provide a value if found - Add proximity and origin CLLocationCoordinate2D fields to Discover.Option and forward these to SearchOption parameters - This fixes an issue when using search-along-route to query category results by providing a country, proximity, and origin parameters to Discover.Options. ### Checklist - [x] Update `CHANGELOG` [SSDK-399]: https://mapbox.atlassian.net/browse/SSDK-399
- Loading branch information
Showing
9 changed files
with
814 additions
and
7 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
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
46 changes: 46 additions & 0 deletions
46
Tests/MapboxSearchIntegrationTests/DiscoverIntegrationTests.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,46 @@ | ||
import CoreLocation | ||
@testable import MapboxSearch | ||
import XCTest | ||
|
||
class DiscoverIntegrationTests: MockServerIntegrationTestCase { | ||
lazy var searchEngine = Discover(locationProvider: DefaultLocationProvider()) | ||
|
||
func testCategorySearchAlongRouteWithCountryProximityOrigin() throws { | ||
try server.setResponse(.categoryHotelSearchAlongRoute_JP) | ||
let expectation = XCTestExpectation(description: "Expecting results") | ||
|
||
let coordinate1 = CLLocationCoordinate2D(latitude: 35.655614, longitude: 139.7081684) | ||
let coordinate2 = CLLocationCoordinate2D(latitude: 35.6881616, longitude: 139.6994339) | ||
let coordinates = [coordinate1, coordinate2] | ||
|
||
let mapboxSearchRoute = MapboxSearch.Route(coordinates: coordinates) | ||
let rOptions: MapboxSearch.RouteOptions = RouteOptions(route: mapboxSearchRoute, time: 1000) | ||
|
||
let discoverOptions = Discover.Options( | ||
limit: 10, | ||
language: nil, | ||
country: Country(countryCode: "jp"), | ||
proximity: CLLocationCoordinate2D( | ||
latitude: 35.6634363, | ||
longitude: 139.7394536 | ||
), | ||
origin: CLLocationCoordinate2D(latitude: 35.66580, longitude: 139.74609) | ||
) | ||
|
||
searchEngine.search( | ||
for: Discover.Query.Category.canonicalName("hotel"), | ||
route: rOptions, | ||
options: discoverOptions | ||
) { 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) | ||
} | ||
} |
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
Oops, something went wrong.