zeroclickinfo-goodies/t/UN.t

68 lines
1.7 KiB
Perl
Raw Permalink Normal View History

2012-05-05 14:14:07 -07:00
#!/usr/bin/env perl
use utf8;
use strict;
use warnings;
2015-09-28 11:19:43 -07:00
2012-05-05 14:14:07 -07:00
use Test::More;
use Test::Deep;
2012-05-05 14:14:07 -07:00
use DDG::Test::Goodie;
2015-09-28 11:19:43 -07:00
zci answer_type => 'united_nations';
2012-05-05 14:14:07 -07:00
zci is_cached => 1;
2015-09-28 11:19:43 -07:00
sub build_structure
{
my ($num, $result, $link) = @_;
return $result, structured_answer => {
data => {
title => "UN Number: " . $num,
description => $result
},
meta => {
sourceName => "Wikipedia",
sourceUrl => $link
},
templates => {
group => 'info',
options => {
moreAt => 1
}
}
};
}
2012-05-05 14:14:07 -07:00
ddg_goodie_test(
2015-09-28 11:19:43 -07:00
[qw(DDG::Goodie::UN)],
2015-09-28 14:33:58 -07:00
"un 9" => test_zci(
build_structure(
"0009",
"Ammunition, incendiary with or without burster, expelling charge, or propelling charge",
"https://en.wikipedia.org/wiki/List_of_UN_numbers_0001_to_0100"
)
),
"un number 9" => test_zci(
build_structure(
"0009",
"Ammunition, incendiary with or without burster, expelling charge, or propelling charge",
"https://en.wikipedia.org/wiki/List_of_UN_numbers_0001_to_0100"
)
),
"un number 0009" => test_zci(
build_structure(
"0009",
"Ammunition, incendiary with or without burster, expelling charge, or propelling charge",
"https://en.wikipedia.org/wiki/List_of_UN_numbers_0001_to_0100"
)
),
"un 1993" => test_zci(
build_structure(
2015-09-28 14:34:39 -07:00
"1993",
"Combustible liquids, n.o.s",
"https://en.wikipedia.org/wiki/List_of_UN_numbers_1901_to_2000"
2015-09-28 14:33:58 -07:00
)
),
2015-09-28 11:19:43 -07:00
"un number foo" => undef,
2012-05-05 14:14:07 -07:00
);
done_testing;