2015-09-03 18:04:11 -07:00
|
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
use warnings;
|
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
|
use Test::Deep;
|
2015-09-03 18:04:11 -07:00
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
use utf8; # needed to properly use the various unicode characters in the emoticons
|
|
|
|
|
|
|
|
|
|
zci answer_type => "shruggie";
|
|
|
|
|
zci is_cached => 1;
|
|
|
|
|
|
2015-09-05 19:06:22 -07:00
|
|
|
|
sub build_structure
|
|
|
|
|
{
|
2015-10-27 07:22:56 -07:00
|
|
|
|
my ($string, $data, $keys) = @_;
|
|
|
|
|
return {
|
2015-09-05 19:06:22 -07:00
|
|
|
|
description => 'Emojii for everone',
|
|
|
|
|
templates => {
|
|
|
|
|
group => 'list',
|
|
|
|
|
options => {
|
|
|
|
|
content => 'record'
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-10-27 07:22:56 -07:00
|
|
|
|
meta => {
|
|
|
|
|
sourceName => "Donger List",
|
|
|
|
|
sourceUrl => "http://dongerlist.com/"
|
|
|
|
|
},
|
2015-09-05 19:06:22 -07:00
|
|
|
|
data => {
|
|
|
|
|
title => $string,
|
|
|
|
|
record_data => $data,
|
|
|
|
|
record_keys => $keys
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-09-03 18:04:11 -07:00
|
|
|
|
ddg_goodie_test(
|
|
|
|
|
[qw( DDG::Goodie::Shruggie )],
|
|
|
|
|
# At a minimum, be sure to include tests for all:
|
2015-10-27 07:22:56 -07:00
|
|
|
|
|
2015-09-03 18:04:11 -07:00
|
|
|
|
# - primary_example_queries
|
2015-10-27 07:22:56 -07:00
|
|
|
|
'shruggie' => test_zci('¯\_(ツ)_/¯',
|
|
|
|
|
structured_answer => {
|
2015-09-05 19:06:22 -07:00
|
|
|
|
description => 'Emojii for everone',
|
|
|
|
|
templates => {
|
|
|
|
|
group => 'text'
|
|
|
|
|
},
|
|
|
|
|
data => {
|
|
|
|
|
title => '¯\_(ツ)_/¯',
|
|
|
|
|
#subtitle => "Shruggie" #I like it better without this, but either way is cool
|
|
|
|
|
}}),
|
2015-09-03 18:04:11 -07:00
|
|
|
|
# The next test stresses the JSON file
|
2015-10-27 07:22:56 -07:00
|
|
|
|
# I am sure there is a better way to do this, but I can't figure out the
|
2015-09-03 18:04:11 -07:00
|
|
|
|
# required regex
|
2015-09-05 19:06:22 -07:00
|
|
|
|
#'shruggie and friends' => test_zci("Shruggie and Friends"),
|
|
|
|
|
#
|
2015-10-27 07:22:56 -07:00
|
|
|
|
|
2015-09-03 18:04:11 -07:00
|
|
|
|
# - secondary_example_queries
|
|
|
|
|
# Test three random emojiis. Because the config file for the emojiis is
|
|
|
|
|
# desgined to be easily modified to, a full test is not a great idea
|
2015-09-05 19:06:22 -07:00
|
|
|
|
'shruggie and Table Flip' => test_zci('Shruggie and Table Flip',
|
|
|
|
|
structured_answer => build_structure("Shruggie and Table Flip",{
|
2015-10-27 07:22:56 -07:00
|
|
|
|
"Shruggie" => '¯\_(ツ)_/¯',
|
|
|
|
|
"Table Flip" => "(╯°□°)╯︵ ┻━┻",
|
|
|
|
|
},
|
|
|
|
|
["Shruggie", "Table Flip"]
|
|
|
|
|
)),
|
2015-09-05 19:06:22 -07:00
|
|
|
|
'shruggie and Anon' => test_zci('Shruggie and Anon',
|
|
|
|
|
structured_answer => build_structure('Shruggie and Anon',{
|
2015-10-27 07:22:56 -07:00
|
|
|
|
"Shruggie" => '¯\_(ツ)_/¯',
|
|
|
|
|
"Anon" => "ლ(ಠ益ಠლ)"
|
|
|
|
|
},
|
|
|
|
|
["Shruggie", "Anon"]
|
|
|
|
|
)),
|
2015-09-05 19:06:22 -07:00
|
|
|
|
'shruggie AND hug me' => test_zci('Shruggie and Hug Me',
|
|
|
|
|
structured_answer => build_structure('Shruggie and Hug Me',{
|
2015-10-27 07:22:56 -07:00
|
|
|
|
"Shruggie" => '¯\_(ツ)_/¯',
|
|
|
|
|
"Hug Me" => "(っ◕‿◕)っ",
|
|
|
|
|
},
|
|
|
|
|
["Shruggie", "Hug Me"]
|
|
|
|
|
)),
|
|
|
|
|
|
2015-09-03 18:04:11 -07:00
|
|
|
|
# Try to include some examples of queries on which it might
|
|
|
|
|
# appear that your answer will trigger, but does not.
|
|
|
|
|
'shruggie and' => undef,
|
|
|
|
|
'shruggie and friendss' => undef,
|
|
|
|
|
'shruggie andover' => undef
|
|
|
|
|
);
|
|
|
|
|
|
2016-05-16 06:18:04 -07:00
|
|
|
|
done_testing;
|