aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/around.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/around.t')
-rw-r--r--t/app/controller/around.t74
1 files changed, 73 insertions, 1 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t
index 021cf8f7d..069ec605a 100644
--- a/t/app/controller/around.t
+++ b/t/app/controller/around.t
@@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new;
subtest "check that if no query we get sent back to the homepage" => sub {
$mech->get_ok('/around');
- is $mech->uri->path, '/', "sent back to '/'";
+ is $mech->uri->path, '/around', "still at '/around'";
};
# x,y requests were generated by the old map code. We keep the behavior for
@@ -28,4 +28,76 @@ subtest "redirect x,y requests to lat/lon (301 - permanent)" => sub {
};
+# test various locations on inital search box
+foreach my $test (
+ {
+ pc => '', #
+ errors => [],
+ pc_alternatives => [],
+ },
+ {
+ pc => 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
+ errors => ['Sorry, we could not find that location.'],
+ pc_alternatives => [],
+ },
+ {
+ pc => 'glenthorpe',
+ errors => [],
+ pc_alternatives => [ # TODO - should filter out these non-UK addresses
+ 'Glenthorpe Crescent, Leeds LS9 7',
+ 'Glenthorpe Rd, Merton, Greater London SM4 4',
+ 'Glenthorpe Ln, Katy, TX 77494, USA',
+ 'Glenthorpe Dr, Walnut, CA 91789, USA',
+ 'Glenthorpe Ave, Leeds LS9 7',
+ 'Glenthorpe Ct, Katy, TX 77494, USA',
+ ],
+ },
+ {
+ pc => 'Glenthorpe Ct, Katy, TX 77494, USA',
+ errors =>
+ ['We had a problem with the supplied co-ordinates - outside the UK?'],
+ pc_alternatives => [],
+ },
+ )
+{
+ subtest "test bad pc value '$test->{pc}'" => sub {
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
+ "bad location" );
+ is_deeply $mech->page_errors, $test->{errors},
+ "expected errors for pc '$test->{pc}'";
+ is_deeply $mech->pc_alternatives, $test->{pc_alternatives},
+ "expected alternatives for pc '$test->{pc}'";
+ };
+}
+
+# check that exact queries result in the correct lat,lng
+foreach my $test (
+ {
+ pc => 'SW1A 1AA',
+ latitude => '51.5010096115539',
+ longitude => '-0.141587067110009',
+ },
+ {
+ pc => 'Manchester',
+ latitude => '53.4807125',
+ longitude => '-2.2343765',
+ },
+ {
+ pc => 'Glenthorpe Rd, Merton, Greater London SM4 4, UK',
+ latitude => '51.3937997',
+ longitude => '-0.2209596',
+ },
+ )
+{
+ subtest "check lat/lng for '$test->{pc}'" => sub {
+ $mech->get_ok('/');
+ $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } },
+ "good location" );
+ is_deeply $mech->form_errors, [], "no errors for pc '$test->{pc}'";
+ is_deeply $mech->extract_location, $test,
+ "got expected location for pc '$test->{pc}'";
+ };
+}
+
done_testing();