Debian lenny version packages
[pkg-perl] / deb-src / libhtml-tree-perl / libhtml-tree-perl-3.23 / t / tag-rendering.t
1 #!perl -w
2
3 use Test::More tests => 8;
4 use strict;
5
6 BEGIN {
7     use_ok( "HTML::Element" );
8 }
9
10
11 my $img =
12     HTML::Element->new( 'img', (
13         src => 'damian-conway-in-a-dress.jpg',
14         height=>540, width=>100, border=>0,
15         alt => "A few bottles of Chech'tluth later...",
16     ) );
17
18 my $href = '/report/fullcsv';
19 my $literal_href = HTML::Element->new(
20   '~literal', 'text' => "window.location.href='$href'"
21  );
22 $img->attr(onClick => $literal_href);
23
24
25
26
27 isa_ok( $img, 'HTML::Element' );
28 my $html = $img->as_HTML;
29 print $html, "\n";
30
31 like( $html, qr/<img .+ \/>/,    "Tag is self-closed" );
32 like( $html, qr/ height="540" /, "Height is quoted" );
33 like( $html, qr/ border="0" /,   "Border is quoted" );
34 like( $html, qr/ width="100" /,  "Width is quoted" );
35 like( 
36   $html, 
37   qr! onclick="window.location.href='$href'!,
38   "Literal text is preserved" 
39  );
40 like( $html, qr/ alt="A few bottles of Chech&#39;tluth later..." /, "Alt tag is quoted and escaped" );