@panoramax/web-viewer
Version:
Panoramax web viewer for geolocated pictures
38 lines (31 loc) • 1.23 kB
JavaScript
import * as geocoder from "../../src/utils/geocoder";
import GEOCODER_NOMINATIM from "../data/Map_geocoder_nominatim.json";
import GEOCODER_BAN from "../data/Map_geocoder_ban.json";
describe("forwardGeocodingNominatim", () => {
it("works", () => {
// Mock API search
global.fetch = jest.fn(() => Promise.resolve({
json: () => GEOCODER_NOMINATIM
}));
// Search config
const cfg = { query: "bla", limit: 5, bbox: "17.7,-45.2,17.8,-45.1" };
return geocoder.forwardGeocodingNominatim(cfg).then(res => {
expect(global.fetch.mock.calls).toEqual([["https://nominatim.openstreetmap.org/search?q=bla&limit=5&viewbox=17.7%2C-45.2%2C17.8%2C-45.1&format=geocodejson&addressdetails=1"]]);
expect(res).toMatchSnapshot();
});
});
});
describe("forwardGeocodingBAN", () => {
it("works", () => {
// Mock API search
global.fetch = jest.fn(() => Promise.resolve({
json: () => GEOCODER_BAN
}));
// Search config
const cfg = { query: "bla", limit: 5, proximity: "17.7,-45.2" };
return geocoder.forwardGeocodingBAN(cfg).then(res => {
expect(global.fetch.mock.calls).toEqual([["https://data.geopf.fr/geocodage/search/?q=bla&limit=5&lat=17.7&lon=-45.2"]]);
expect(res).toMatchSnapshot();
});
});
});