-
Notifications
You must be signed in to change notification settings - Fork 22
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
3 changed files
with
14 additions
and
8 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 |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import { createReverseGeocode } from './reverseGeocode'; | ||
import { expect, it } from 'vitest'; | ||
|
||
const reverseGeocode = createReverseGeocode({ | ||
mapboxAccessToken: process.env.MAPBOX_ACCESS_TOKEN || 'YOUR_FALLBACK_MAPBOX_ACCESS_TOKEN', | ||
}); | ||
|
||
it('should successfully return an address from coordinates', async () => { | ||
const reverseGeocode = createReverseGeocode({ | ||
mapboxAccessToken: process.env.MAPBOX_ACCESS_TOKEN || 'YOUR_FALLBACK_MAPBOX_ACCESS_TOKEN', | ||
}); | ||
|
||
const result = await reverseGeocode.execute({ | ||
latitude: 40.7128, | ||
longitude: -74.006, | ||
}); | ||
|
||
console.log(result) | ||
|
||
expect(result).toMatchObject({ | ||
address: expect.stringContaining(','), | ||
}); | ||
}); | ||
|
||
// throw error if not mapbox access token | ||
it ('should throw an error if no mapbox access token', async () => { | ||
// createReverseGeocode will throw an error if no mapbox access token | ||
expect(() => createReverseGeocode({mapboxAccessToken: ''})).toThrow(); | ||
}); | ||
|
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