use strict; use Test::Base; use HTML::MobileJp::Filter; use HTTP::MobileAgent; use utf8; if (-e 't/emoticon.yaml') { plan tests => 1 * blocks; } else { plan skip_all => 't/emoticon.yaml not found'; } filters { user_agent => [qw/ chomp /], config => [qw/ yaml /], input => [qw/ chomp /], expected => [qw/ chomp /], }; run { my $block = shift; my $filter = HTML::MobileJp::Filter->new($block->config); my $html = $filter->filter( mobile_agent => HTTP::MobileAgent->new($block->user_agent), html => $block->input, ); is($html, $block->expected, $block->name); }; __DATA__ === fallback TypeCast image --- user_agent Mozilla/5.0 --- config filters: - module: PictogramFallback::TypeCast config: emoticon_yaml: t/emoticon.yaml template: --- input eval "\x{E63E}\x{E309}\x{ECA2}" --- expected eval "\x{E309}\x{ECA2}" === fallback TypeCast image and fallback_name --- user_agent Mozilla/5.0 --- config filters: - module: PictogramFallback::TypeCast config: emoticon_yaml: t/emoticon.yaml template: - module: PictogramFallback config: template: %s params: - fallback_name --- input eval "\x{E63E}\x{E309}\x{ECA2}" --- expected [WC](>3<) === fallback TypeCast image and fallback_name_htmlescape --- user_agent Mozilla/5.0 --- config filters: - module: PictogramFallback::TypeCast config: emoticon_yaml: t/emoticon.yaml template: - module: PictogramFallback config: template: %s params: - fallback_name_htmlescape --- input eval "\x{E63E}\x{E309}\x{ECA2}" --- expected [WC](>3<) === put pictograms as an entity reference --- user_agent Mozilla/5.0 --- config filters: - module: EntityReference config: force: 1 --- input 冨 --- expected eval "\x{E63E}冨"