diff --git a/lib/DDG/Goodie/PhoneAlphabet.pm b/lib/DDG/Goodie/PhoneAlphabet.pm index c47bf0ca2..19b9dffa0 100644 --- a/lib/DDG/Goodie/PhoneAlphabet.pm +++ b/lib/DDG/Goodie/PhoneAlphabet.pm @@ -22,11 +22,14 @@ handle remainder => sub { # Use a regex to replace each letter with the corresponding number from the phone key pad. $num =~ tr/abcdefghijklmnopqrstuvwxyz/22233344455566677778889999/; - return "Phone Number: $num", - structured_answer => { - input => [html_enc($input)], - operation => "Phone Number", - result => "$num", + return "Phone Number: $num", structured_answer => { + data => { + title => $num, + subtitle => "Phone Number: ".html_enc($input) + }, + templates => { + group => 'text' + } }; }; diff --git a/t/PhoneAlphabet.t b/t/PhoneAlphabet.t index aa9c9f790..d09bb031e 100644 --- a/t/PhoneAlphabet.t +++ b/t/PhoneAlphabet.t @@ -9,53 +9,26 @@ use DDG::Test::Goodie; zci answer_type => "phone_alphabet"; zci is_cached => 1; +sub build_test { + my($text, $input, $number) = @_; + return test_zci($text, structured_answer => { + data => { + title => $number, + subtitle => "Phone Number: $input" + }, + templates => { + group => 'text' + } + }); +} + ddg_goodie_test( [qw( DDG::Goodie::PhoneAlphabet )], - '1-800-LAWYR-UP to digits' => test_zci( - 'Phone Number: 1-800-52997-87', - structured_answer => { - input => ['1-800-LAWYR-UP'], - operation => 'Phone Number', - result => '1-800-52997-87' - } - ), - - '1-800-fun-hack to phone number' => test_zci( - 'Phone Number: 1-800-386-4225', - structured_answer => { - input => ['1-800-fun-hack'], - operation => 'Phone Number', - result => '1-800-386-4225' - } - ), - '1-800-fun-hack to numbers' => test_zci( - 'Phone Number: 1-800-386-4225', - structured_answer => { - input => ['1-800-fun-hack'], - operation => 'Phone Number', - result => '1-800-386-4225' - } - ), - - - '1958funhack to phone' => test_zci( - 'Phone Number: 19583864225', - structured_answer => { - input => ['1958funhack'], - operation => 'Phone Number', - result => '19583864225' - } - ), - - '13TAXI to phone' => test_zci( - 'Phone Number: 138294', - structured_answer => { - input => ['13TAXI'], - operation => 'Phone Number', - result => '138294' - } - ), - + '1-800-LAWYR-UP to digits' => build_test('Phone Number: 1-800-52997-87', '1-800-LAWYR-UP', '1-800-52997-87'), + '1-800-fun-hack to phone number' => build_test('Phone Number: 1-800-386-4225', '1-800-fun-hack', '1-800-386-4225'), + '1-800-fun-hack to numbers' => build_test('Phone Number: 1-800-386-4225', '1-800-fun-hack', '1-800-386-4225'), + '1958funhack to phone' => build_test('Phone Number: 19583864225', '1958funhack', '19583864225'), + '13TAXI to phone' => build_test('Phone Number: 138294', '13TAXI', '138294'), 'something fun to hack to phone' => undef, '0x0123 to digits' => undef );