-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ test.js | |
package-lock.json | ||
playground.js | ||
.github | ||
|
||
integration_test |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
'use strict'; | ||
|
||
var GeocoderFactory = require('./lib/geocoderfactory.js'); | ||
const GeocoderFactory = require('./lib/geocoderfactory.js'); | ||
|
||
var Exports = GeocoderFactory.getGeocoder.bind(GeocoderFactory); | ||
const Exports = GeocoderFactory.getGeocoder.bind(GeocoderFactory); | ||
|
||
module.exports = Exports; |
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,58 @@ | ||
const NodeGeocoder = require('../../index'); | ||
|
||
describe('Mapbox geocoder', () => { | ||
let geocoder; | ||
|
||
beforeAll(() => { | ||
const apiKey = process.env.MAPBOX_API_KEY; | ||
const options = { | ||
provider: 'mapbox', | ||
apiKey | ||
}; | ||
|
||
if (!apiKey || apiKey === '') { | ||
throw new Error('MAPBOX_API_KEY not configured'); | ||
} | ||
|
||
geocoder = NodeGeocoder(options); | ||
}); | ||
|
||
describe('geocode', () => { | ||
it('works', async () => { | ||
const res = await geocoder.geocode('1231 Av. Lajoie, Montreal'); | ||
|
||
expect(res[0]).toBeDefined(); | ||
expect(res[0]).toMatchObject({ | ||
latitude: 45.521056, | ||
longitude: -73.610734, | ||
formattedAddress: | ||
'1231 Avenue Lajoie, Montréal, Quebec H2V 1P2, Canada', | ||
country: 'Canada', | ||
countryCode: 'CA', | ||
state: 'Quebec', | ||
city: 'Montréal', | ||
zipcode: 'H2V 1P2', | ||
neighbourhood: 'Outremont' | ||
}); | ||
}); | ||
}); | ||
|
||
describe('reverse', () => { | ||
it('works', async () => { | ||
const res = await geocoder.reverse({ lat: 45.521056, lon: -73.610734 }); | ||
expect(res[0]).toBeDefined(); | ||
expect(res[0]).toMatchObject({ | ||
latitude: 45.52105585, | ||
longitude: -73.61073425, | ||
formattedAddress: | ||
'1231 Avenue Lajoie, Montréal, Quebec H2V 1P2, Canada', | ||
country: 'Canada', | ||
countryCode: 'CA', | ||
state: 'Quebec', | ||
city: 'Montréal', | ||
zipcode: 'H2V 1P2', | ||
neighbourhood: 'Outremont' | ||
}); | ||
}); | ||
}); | ||
}); |
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