[openstreetmap/openstreetmap-website] Get directions using fetch (PR #5642)
Holger Jeromin
notifications at github.com
Tue Feb 11 13:02:19 UTC 2025
> I still don't know what I need to change in the testing stub
I would guess:
```ruby
def stub_straight_routing(start_instruction: "Start here", finish_instruction: "Finish there")
stub_routing <<~CALLBACK
const distance = points[0].distanceTo(points[1]);
const time = distance * 30;
return Promise.resolve({
line: points,
steps: [
[points[0], 8, "<b>1.</b> #{start_instruction}", distance, points],
[points[1], 14, "<b>2.</b> #{finish_instruction}", 0, [points[1]]]
],
distance,
time
});
CALLBACK
end
def stub_routing(callback_code)
execute_script <<~SCRIPT
$(() => {
for (const engine of OSM.Directions.engines) {
engine.getRoute = (points, signal) => {
#{callback_code}
};
}
});
SCRIPT
end
end
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5642#issuecomment-2650757462
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5642/c2650757462 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250211/6b1b0500/attachment.htm>
More information about the rails-dev
mailing list