test: add coverage for PR #385 (nominatim endpoint & geocoder)#443
Merged
DennisOSRM merged 6 commits intogh-pagesfrom May 3, 2026
Merged
test: add coverage for PR #385 (nominatim endpoint & geocoder)#443DennisOSRM merged 6 commits intogh-pagesfrom
DennisOSRM merged 6 commits intogh-pagesfrom
Conversation
Most of API endpoints can be modified via leaflet_options.js, which is mentioned in README as a target of manual modify. But nominatim endpoint cannot be modified by this way. As nominatim can be self-hosted, I think it should be modifiable in configuration.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…eserving) Adds unit tests for scripts/replace.applyReplacements (NOMINATIM_ENDPOINT) and src/geocoder.coordPreserving serviceUrl/coordinate preservation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Jest coverage and wiring to allow overriding the Nominatim endpoint via NOMINATIM_ENDPOINT, and ensures coordPreserving passes a configurable Nominatim serviceUrl while preserving typed coordinate centers.
Changes:
- Added unit tests for
applyReplacementsNominatim URL replacement andgeocoder.coordPreservingserviceUrl + coordinate preservation behavior. - Added
leafletOptions.nominatim.pathdefault and threaded it intocreateGeocoder.coordPreserving(...). - Updated
geocoder.coordPreservingto accept a Nominatim URL and pass it toL.Control.Geocoder.nominatim.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/replace_nominatim.test.js | Adds tests for NOMINATIM endpoint replacement behavior. |
| test/geocoder.test.js | Adds tests for coord input preservation and serviceUrl being passed. |
| src/leaflet_options.js | Introduces a default Nominatim endpoint in options. |
| src/index.js | Passes configured Nominatim endpoint into coordPreserving. |
| src/geocoder.js | Adds a nominatimUrl parameter and forwards it to Leaflet-Control-Geocoder. |
| scripts/replace.js | Adds NOMINATIM_ENDPOINT replacement support. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| geocoder.coordPreserving = function() { | ||
| var nominatim = L.Control.Geocoder.nominatim(); | ||
| geocoder.coordPreserving = function(nominatimUrl) { | ||
| var nominatim = L.Control.Geocoder.nominatim({serviceUrl: nominatimUrl}); |
| // Leaflet uses LatLng | ||
| else options = options.replace('38.8995,-77.0269', latlng) | ||
| } | ||
| if (NOMINATIM_ENDPOINT) options = options.replace('https://nominatim.openstreetmap.org/', NOMINATIM_ENDPOINT) |
Comment on lines
+23
to
+24
| const g = geocoder.coordPreserving('https://nominatim.example/'); | ||
| expect(L.Control.Geocoder.nominatim).toHaveBeenCalledWith({ serviceUrl: 'https://nominatim.example/' }); |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds unit tests for NOMINATIM_ENDPOINT replacement and geocoder.coordPreserving serviceUrl/coordinate preservation.