Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Mar 1, 2024
1 parent 727e656 commit 572cc88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions route-snapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ impl JsRouteSnapper {
impl JsRouteSnapper {
// Snaps first to free-drawn points, then nodes
fn mouseover_something(&self, pt: Coord, circle_radius_meters: f64) -> Option<Waypoint> {
// TODO For very long routes, this'll get slow
for waypt in &self.route.waypoints {
if let Waypoint::Free(x) = waypt {
if Point::from(*x).haversine_distance(&Point::from(pt)) < circle_radius_meters {
Expand Down
9 changes: 3 additions & 6 deletions route-snapper/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn test_area() {
// Drag something in between 1 and 2
let intermediate = find_intermediate_point(&snapper, WAYPT1, WAYPT2);
// Just make sure it's not one of the arbitrary IDs we chose. Manually figured out this ID.
assert_eq!(intermediate, Waypoint::Snapped(NodeID(4868)));
assert_eq!(intermediate, Waypoint::Snapped(NodeID(6235)));
drag(&mut snapper, intermediate, WAYPT4);
// We should've introduced a new waypoint
assert_eq!(
Expand Down Expand Up @@ -189,12 +189,9 @@ fn test_area() {

// Simulate the mouse being somewhere
fn optionally_mouseover_waypt(snapper: &mut JsRouteSnapper, waypt: Waypoint) {
let gps = snapper
.to_pt(waypt)
.to_pt2d()
.to_gps(&snapper.router.map.gps_bounds);
let pt = unhash_pt(snapper.to_pt(waypt));
let circle_radius_meters = 1.0;
snapper.on_mouse_move(gps.x(), gps.y(), circle_radius_meters);
snapper.on_mouse_move(pt.x, pt.y, circle_radius_meters);
}

// Simulate the mouse being somewhere, then check the tool is hovering on that waypoint
Expand Down

0 comments on commit 572cc88

Please sign in to comment.