zeroclickinfo-goodies/t/HelpLine.t

69 lines
1.4 KiB
Perl
Raw Normal View History

2013-06-21 13:35:10 -07:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
use DDG::Test::Location;
use DDG::Request;
2013-06-21 13:35:10 -07:00
zci answer_type => 'helpline';
my @queries = (
'suicide',
2014-01-23 21:21:43 -08:00
'suicide hotline',
'kill myself',
'suicidal thoughts',
2014-01-23 21:21:43 -08:00
'end my life',
'suicidal thoughts',
'suicidal',
'suicidal ideation',
'i want to kill myself',
'commit suicide',
'suicide pills',
'suicide pill',
'suicide prevention',
'kill myself',
);
my @locations = (
2014-01-23 21:21:43 -08:00
'au',
'us',
2014-01-23 21:21:43 -08:00
);
my @ok_queries = (
'suicide girls',
'suicide silence',
);
2013-06-21 13:35:10 -07:00
ddg_goodie_test(
[qw(
DDG::Goodie::HelpLine
)],
(map {
my $query = $queries[$_];
map {
DDG::Request->new(
query_raw => "$query",
location => test_location("$locations[$_]")
),
2014-01-29 12:27:28 -08:00
test_zci(qr/24 Hour Suicide Hotline/),
} 0 .. scalar @locations - 1
} 0 .. scalar @queries - 1),
(map {
2014-01-23 21:21:43 -08:00
my $query = $ok_queries[$_];
map {
DDG::Request->new(
query_raw => "$query",
location => test_location("$locations[$_]")
),
undef
} 0 .. scalar @locations - 1
2014-01-23 21:21:43 -08:00
} 0 .. scalar @ok_queries - 1),
2013-06-21 13:35:10 -07:00
);
done_testing(
(scalar @queries * scalar @locations * 2) +
2014-01-23 21:21:43 -08:00
(scalar @ok_queries * scalar @locations)
);