forked from svoynow/elm-google-geocoding
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTests.elm
174 lines (136 loc) · 5.22 KB
/
Tests.elm
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
module Tests exposing (..)
import Test exposing (..)
import Expect
import Geocoding as G
apiKey : String
apiKey =
"ABCD"
testInitializeWithAddressOnly : Test
testInitializeWithAddressOnly =
let
request =
G.requestForAddress apiKey "77 Battery St."
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&address=77+Battery+St."
in
test "initializeWithAddressOnly" <|
\() -> Expect.equal (G.requestUrl request) expected
testInitializeWithComponentsOnly : Test
testInitializeWithComponentsOnly =
let
request =
G.requestForComponents apiKey [ ( "Spain", G.CountryComponent ) ]
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&components=country%3ASpain"
in
test "initializeWithComponentsOnly" <|
\() -> Expect.equal (G.requestUrl request) expected
testWithAddress : Test
testWithAddress =
let
request =
G.requestForComponents apiKey [ ( "Spain", G.CountryComponent ) ]
|> G.withAddress ("Toledo")
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&address=Toledo&components=country%3ASpain"
in
test "withAddress" <|
\() -> Expect.equal (G.requestUrl request) expected
testWithComponents : Test
testWithComponents =
let
request =
G.requestForAddress apiKey "Toledo"
|> G.withComponent ( "Spain", G.CountryComponent )
|> G.withComponent ( "Toledo", G.AdministrativeAreaComponent )
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&address=Toledo&components=administrative_area%3AToledo%7Ccountry%3ASpain"
in
test "withComponents" <|
\() -> Expect.equal (G.requestUrl request) expected
testWithRegion : Test
testWithRegion =
let
request =
G.requestForAddress apiKey "Toledo"
|> G.withRegion "ES"
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&address=Toledo®ion=ES"
in
test "withRegion" <|
\() -> Expect.equal (G.requestUrl request) expected
testWithLanguage : Test
testWithLanguage =
let
request =
G.requestForAddress apiKey "Toledo"
|> G.withLanguage "ES"
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&address=Toledo&language=ES"
in
test "withLanguage" <|
\() -> Expect.equal (G.requestUrl request) expected
testWithBounds : Test
testWithBounds =
let
request =
G.requestForAddress apiKey "Belmont"
|> G.withBounds ( 41, -74 ) ( 42, -70 )
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&address=Belmont&bounds=41%2C-74%7C42%2C-70"
in
test "withBounds" <|
\() -> Expect.equal (G.requestUrl request) expected
testReverseForLatLng : Test
testReverseForLatLng =
let
request =
G.reverseRequestForLatLng apiKey ( 37.8489277, -122.4031502 )
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&latlng=37.8489277%2C-122.4031502"
in
test "reverseForLatLng" <|
\() -> Expect.equal (G.reverseRequestUrl request) expected
testReverseForPlaceId : Test
testReverseForPlaceId =
let
request =
G.reverseRequestForPlaceId apiKey "ChIJIQBpAG2ahYAR_6128GcTUEo"
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&place_id=ChIJIQBpAG2ahYAR_6128GcTUEo"
in
test "reverseForPlaceId" <|
\() -> Expect.equal (G.reverseRequestUrl request) expected
testReverseWithLanguage : Test
testReverseWithLanguage =
let
request =
G.reverseRequestForLatLng apiKey ( 37.8489277, -122.4031502 )
|> G.reverseWithLanguage "FR"
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&latlng=37.8489277%2C-122.4031502&language=FR"
in
test "reverseWithLanguage" <|
\() -> Expect.equal (G.reverseRequestUrl request) expected
testReverseWithResultTypes : Test
testReverseWithResultTypes =
let
request =
G.reverseRequestForLatLng apiKey ( 37.8489277, -122.4031502 )
|> G.withResultTypes [ G.StreetAddress, G.Country ]
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&latlng=37.8489277%2C-122.4031502&result_type=street_address%7Ccountry"
in
test "reverseWithResultTypes" <|
\() -> Expect.equal (G.reverseRequestUrl request) expected
testReverseWithLocationTypes : Test
testReverseWithLocationTypes =
let
request =
G.reverseRequestForLatLng apiKey ( 37.8489277, -122.4031502 )
|> G.withLocationTypes [ G.Rooftop, G.Approximate ]
expected =
"https://maps.googleapis.com/maps/api/geocode/json?key=ABCD&latlng=37.8489277%2C-122.4031502&location_type=ROOFTOP%7CAPPROXIMATE"
in
test "reverseWithLocationTypes" <|
\() -> Expect.equal (G.reverseRequestUrl request) expected