zeroclickinfo-goodies/t/CurrencyIn.t

89 lines
2.0 KiB
Perl
Raw Normal View History

2012-04-21 14:19:24 -07:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
2012-04-21 14:19:24 -07:00
use DDG::Test::Goodie;
zci answer_type => 'currency_in';
zci is_cached => 1;
sub build_structure
{
my ($country, $data, $type) = @_;
if($type eq "multiple") {
return $data, structured_answer => {
templates => {
group => 'list',
options => {
content => 'record',
moreAt => 0
}
},
data => {
title => "Currencies in $country",
record_data => $data
}
};
} else {
return $data, structured_answer => {
input => [$country],
operation => "Currency in",
result => $data
};
}
}
2012-04-21 14:19:24 -07:00
ddg_goodie_test(
[qw(DDG::Goodie::CurrencyIn)],
"currency in australia" => test_zci(
build_structure(
"Australia",
2015-10-06 05:45:21 -07:00
"Australian Dollar (AUD)",
"single"
)
),
"currency in AU" => test_zci(
build_structure(
"Australia",
2015-10-06 05:45:21 -07:00
"Australian Dollar (AUD)",
"single"
)
),
"currency in poland" => test_zci(
build_structure(
"Poland",
2015-10-06 05:45:21 -07:00
"Polish Z\x{0142}oty (PLN)",
"single"
)
),
"currency in Alderney" => test_zci(
build_structure(
"Alderney",
{
2015-10-06 05:45:21 -07:00
"NON ISO 4217" => "Alderney Pound",
"GGP" => "Guernsey Pound",
"GBP" => "British Pound"
},
"multiple"
)
),
"currency in zw" => test_zci(
build_structure(
"Zimbabwe",
{
2015-10-06 05:45:21 -07:00
"BWP" => "Botswana Pula",
"EUR" => "Euro",
2015-10-06 05:45:21 -07:00
"ZWL" => "Zimbabwean Dollar",
"ZAR" => "South African Rand",
"USD" => "United States Dollar",
"GBP" => "British Pound",
},
"multiple"
)
)
2012-04-21 14:19:24 -07:00
);
2016-05-16 06:18:04 -07:00
done_testing;