aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Mock/Nominatim.pm5
-rw-r--r--t/app/controller/around.t25
2 files changed, 30 insertions, 0 deletions
diff --git a/t/Mock/Nominatim.pm b/t/Mock/Nominatim.pm
index 806ebbfd3..d108256f5 100644
--- a/t/Mock/Nominatim.pm
+++ b/t/Mock/Nominatim.pm
@@ -1,6 +1,7 @@
package t::Mock::Nominatim;
use JSON::MaybeXS;
+use LWP::Protocol::PSGI;
use Web::Simple;
has json => (
@@ -35,6 +36,10 @@ sub query {
{"osm_type"=>"way","osm_id"=>"4684282","lat"=>"55.9504009","lon"=>"-3.1858425","display_name"=>"High Street, Old Town, City of Ed\x{ed}nburgh, Scotland, EH1 1SP, United Kingdom","class"=>"highway","type"=>"tertiary","importance"=>0.55892577838734},
{"osm_type"=>"node","osm_id"=>"27424410","lat"=>"55.8596449","lon"=>"-4.240377","display_name"=>"High Street, Collegelands, Merchant City, Glasgow, Glasgow City, Scotland, G, United Kingdom","class"=>"railway","type"=>"station","importance"=>0.53074299592768}
];
+ } elsif ($q eq 'edinburgh') {
+ return [
+ {"osm_type"=>"node","osm_id"=>"17898859","lat"=>"55.9533456","lon"=>"-3.1883749","display_name"=>"Edinburgh","class"=>"place","type"=>"place:city","importance"=>0.676704}
+ ];
}
return [];
}
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index be8b0df9e..784801517 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -9,6 +9,7 @@ use constant MIN_ZOOM_LEVEL => 88;
package main;
use Test::MockModule;
+use t::Mock::Nominatim;
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
@@ -89,6 +90,30 @@ foreach my $test (
};
}
+subtest "check lat/lng for full plus code" => sub {
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => "9C7RXR26+R5" } } );
+ is_deeply $mech->page_errors, [], "no errors for plus code";
+ is_deeply $mech->extract_location, {
+ pc => "9C7RXR26+R5",
+ latitude => 55.952063,
+ longitude => -3.189562,
+ },
+ "got expected location for full plus code";
+};
+
+subtest "check lat/lng for short plus code" => sub {
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => "XR26+R5 Edinburgh" } } );
+ is_deeply $mech->page_errors, [], "no errors for plus code";
+ is_deeply $mech->extract_location, {
+ pc => "XR26+R5 Edinburgh",
+ latitude => 55.952063,
+ longitude => -3.189562,
+ },
+ "got expected location for short plus code";
+};
+
my $body_edin_id = $mech->create_body_ok(2651, 'City of Edinburgh Council')->id;
my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id;