#!/usr/bin/perl -T
use strict;
use warnings;
use lib 'lib';
use Mail::SpamAssassin::HTML;
use Test::More;
my @tests = (
{
html => '
X
',
visibility => 'visible',
font_invalid_color => 0,
},
{
html => 'X
',
visibility => 'invisible',
font_invalid_color => 0,
},
{
html => 'X
',
visibility => 'invisible',
font_invalid_color => 0,
},
{
html => 'X
',
visibility => 'invisible',
font_invalid_color => 0,
},
{
html => 'X
',
visibility => 'invisible',
font_invalid_color => 0,
},
{
html => q{X
},
visibility => 'invisible',
font_invalid_color => 0,
},
{
html => q{X
},
visibility => 'invisible',
font_invalid_color => 0,
},
{
html => 'X
',
visibility => 'invisible',
font_invalid_color => 0,
},
{
html => 'X
',
visibility => 'visible',
font_invalid_color => 0,
},
);
plan tests => scalar @tests * 2;
foreach my $test (@tests) {
my $html = $test->{html};
my $html_obj = Mail::SpamAssassin::HTML->new(0,0, debug => 'message');
$html_obj->parse($html);
my $visible_text = $html_obj->get_rendered_text(invisible => 0);
my $invisible_text = $html_obj->get_rendered_text(invisible => 1);
my $visibility =
($visible_text =~ /\S/ ? 'visible' : '') .
($invisible_text =~ /\S/ ? 'invisible' : '');
is($visibility, $test->{visibility}, $html);
my $font_invalid_color = $html_obj->{results}->{font_invalid_color} // 0;
is($font_invalid_color, $test->{font_invalid_color}, $html);
}