Skip to content

Commit 5bdccb8

Browse files
committed
Unit tests
1 parent 454c83c commit 5bdccb8

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

spec/providers/BingProvider.spec.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
describe("Bing Geocoder Provider raw result to Geocoded mapping tests", function() {
2+
var provider = new GeocoderJS.BingProvider(new GeocoderJS.ExternalURILoader()),
3+
geocoded;
4+
5+
var stubBingResult = {
6+
"__type": "Location:http://schemas.microsoft.com/search/local/ws/rest/v1",
7+
"bbox": [
8+
47.636186665473566,
9+
-122.13744013372656,
10+
47.64391210061492,
11+
-122.12215365108256
12+
],
13+
"name": "1 Microsoft Way, Redmond, WA 98052",
14+
"point": {
15+
"type": "Point",
16+
"coordinates": [
17+
47.64004938304424,
18+
-122.12979689240456
19+
]
20+
},
21+
"address": {
22+
"addressLine": "1 Microsoft Way",
23+
"adminDistrict": "WA",
24+
"adminDistrict2": "King Co.",
25+
"countryRegion": "United States",
26+
"formattedAddress": "1 Microsoft Way, Redmond, WA 98052",
27+
"locality": "Redmond",
28+
"postalCode": "98052"
29+
},
30+
"confidence": "High",
31+
"entityType": "Address",
32+
"geocodePoints": [
33+
{
34+
"type": "Point",
35+
"coordinates": [
36+
47.64004938304424,
37+
-122.12979689240456
38+
],
39+
"calculationMethod": "InterpolationOffset",
40+
"usageTypes": [
41+
"Display"
42+
]
43+
},
44+
{
45+
"type": "Point",
46+
"coordinates": [
47+
47.64006815850735,
48+
-122.12985791265965
49+
],
50+
"calculationMethod": "Interpolation",
51+
"usageTypes": [
52+
"Route"
53+
]
54+
}
55+
],
56+
"matchCodes": [
57+
"Good"
58+
]
59+
};
60+
61+
beforeEach(function () {
62+
geocoded = provider.mapToGeocoded(stubBingResult);
63+
});
64+
65+
it ("receives results from the bing geocoder", function() {
66+
expect(geocoded).toBeDefined();
67+
});
68+
69+
it ("maps coordinates correctly", function() {
70+
expect(geocoded.getCoordinates()).toEqual([47.64004938304424, -122.12979689240456]);
71+
});
72+
73+
it ("maps street name correctly", function() {
74+
expect(geocoded.getStreetName()).toEqual("1 Microsoft Way");
75+
});
76+
77+
it ("maps city correctly", function() {
78+
expect(geocoded.getCity()).toEqual("Redmond");
79+
});
80+
81+
it ("maps region correctly", function() {
82+
expect(geocoded.getRegion()).toEqual("WA");
83+
});
84+
85+
it ("maps postal code correctly", function() {
86+
expect(geocoded.getZipcode()).toEqual("98052");
87+
});
88+
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy