-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGeocodingAPIIntegrationTestCase.swift
More file actions
99 lines (84 loc) · 4.68 KB
/
Copy pathGeocodingAPIIntegrationTestCase.swift
File metadata and controls
99 lines (84 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import StadiaMaps
import XCTest
final class GeocodingAPIIntegrationTestCase: IntegrationXCTestCase {
let address = "Põhja pst 27"
func testAutocompleteV1() async throws {
let res = try await GeocodingAPI.autocomplete(text: address, lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties?.country, "Estonia")
XCTAssertEqual(res.features.first?.properties?.layer, "address")
}
func testAutocompleteV2() async throws {
let res = try await GeocodingAPI.autocompleteV2(text: address, lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertNil(res.features.first?.properties.context)
XCTAssertEqual(res.features.first?.properties.layer, "address")
}
func testSearch() async throws {
let res = try await GeocodingAPI.search(text: address, lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties?.country, "Estonia")
XCTAssertEqual(res.features.first?.properties?.layer, "address")
}
func testSearchV2() async throws {
let res = try await GeocodingAPI.searchV2(text: address, lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties.context?.iso3166A3, "EST")
XCTAssertEqual(res.features.first?.properties.layer, "address")
}
func testStructuredSearch() async throws {
let res = try await GeocodingAPI.searchStructured(address: address, region: "Harju", country: "EE", lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties?.country, "Estonia")
XCTAssertEqual(res.features.first?.properties?.layer, "address")
let res2 = try await GeocodingAPI.searchStructured(houseNumber: "27", street: "Põhja pst", locality: "Tallinn", country: "EE", lang: "en")
XCTAssert(!res2.features.isEmpty)
XCTAssertEqual(res2.features.first?.properties?.country, "Estonia")
XCTAssertEqual(res2.features.first?.properties?.layer, "address")
}
func testReverse() async throws {
let res = try await GeocodingAPI.reverse(pointLat: 59.444351, pointLon: 24.750645, layers: [.address, .localadmin], lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties?.country, "Estonia")
}
func testReverseV2() async throws {
let res = try await GeocodingAPI.reverseV2(pointLat: 59.444351, pointLon: 24.750645, layers: [.address, .localadmin], lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties.context?.iso3166A3, "EST")
}
func testReverseUncommonLayer() async throws {
let res = try await GeocodingAPI.reverse(pointLat: 24.750645, pointLon: 59.444351, lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties?.layer, "marinearea")
}
func testReverseUncommonLayerV2() async throws {
let res = try await GeocodingAPI.reverseV2(pointLat: 24.750645, pointLon: 59.444351, lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties.layer, "marinearea")
}
func testPlace() async throws {
let res = try await GeocodingAPI.placeDetails(ids: ["openstreetmap:address:way/109867749"], lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties?.country, "Estonia")
XCTAssertEqual(res.features.first?.properties?.layer, "address")
}
func testPlaceV2() async throws {
let res = try await GeocodingAPI.placeDetailsV2(ids: ["openstreetmap:address:way/109867749"], lang: "en")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties.context?.whosonfirst.country?.name, "Estonia")
XCTAssertEqual(res.features.first?.properties.context?.iso3166A3, "EST")
XCTAssertEqual(res.features.first?.properties.layer, "address")
}
func testBulk() async throws {
let res = try await GeocodingAPI.searchBulk(bulkRequest: [
BulkRequest(endpoint: .slashV1SlashSearch, query: .typeSearchQuery(SearchQuery(text: address, lang: "en"))),
BulkRequest(endpoint: .slashV1SlashSearchSlashStructured, query: .typeSearchStructuredQuery(SearchStructuredQuery(address: address, country: "EE", layers: [.address, .coarse], lang: "en"))),
])
XCTAssertEqual(res.count, 2)
for rec in res {
XCTAssertEqual(rec.status, 200)
XCTAssertEqual(rec.response?.features.first?.properties?.country, "Estonia")
XCTAssertEqual(rec.response?.features.first?.properties?.layer, "address")
}
}
}