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.
Here's some kind of follow-up to #343 where a flaky behaviour was observed during Geocoder unit tests.
Sometimes a strange error was thrown :
TypeError: this.results.forEach is not a function
This happened from the
query
function inside theGeocoderController
called from theGeocoder.vue
component where the actual request was made like this:But with this code, if the underlying
fetch
was in error, the exception was caught then returned which made thePromise
from theGeocoder component
resolve instead of reject. So the error was considered as a result but was anError
instance instead of the expectedArray
of results...This was simply corrected by removing the
try - catch
. If an error is thrown, it is practically caught inside thequerySelections
method of theGeocoder component
as planned first.The other unit tests for the
geocoder
have been slightly refactored to use a fake request instead of doing multiple API calls toNominatim
.Some could argue that there is still a test making a real request and that this shouldn't be done inside unit tests but as this is the one which unveiled the bug corrected in #343 I thought making a real request was valuable in this case.
Please note that this final implementation is perhaps not the best one (
onQueryError()
does nothing except making a call totrace()
) but the bug is corrected and the component should behave as it was designed at first...