zeroclickinfo-goodies/t/RgbColor.t

51 lines
918 B
Perl
Raw Normal View History

2016-07-04 10:57:54 -07:00
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
use DDG::Test::Goodie;
zci answer_type => "rgb_color";
zci is_cached => 0;
2016-07-04 10:57:54 -07:00
sub build_structured_answer {
my @test_params = @_;
my %answer = build_answer_random();
return $answer{text_answer},
2016-07-04 10:57:54 -07:00
structured_answer => {
data => $answer{data},
2016-07-04 10:57:54 -07:00
templates => {
group => "text",
}
};
}
my $color_re = qr/\p{XDigit}{6}/i;
sub build_answer_random {
return (
text_answer => re($color_re),
data => {
title => re($color_re),
subtitle => 'Random color',
},
);
}
2016-07-04 10:57:54 -07:00
sub build_test { test_zci(build_structured_answer(@_)) }
ddg_goodie_test(
[qw( DDG::Goodie::RgbColor )],
# Random colors
'random color' => build_test(),
2016-07-05 01:38:04 -07:00
# Using 'colour'
'random colour' => build_test(),
2016-07-04 10:57:54 -07:00
);
done_testing;