From: Simon Elliott Date: Thu, 9 Jun 2011 14:20:37 +0000 (+0100) Subject: tests for issues with void elements. X-Git-Tag: release_0.009007_1~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=3bb32b1a25bec882416bcbc45cfea575700baaa1 tests for issues with void elements. --- diff --git a/t/bugs/form_helpers.t b/t/bugs/form_helpers.t new file mode 100644 index 0000000..5b674c1 --- /dev/null +++ b/t/bugs/form_helpers.t @@ -0,0 +1,53 @@ +use strictures 1; +use Test::More; + +use HTML::Zoom; + +my $tmpl =< +
+ + + + + + + + + + +
+ +END + +my $z = HTML::Zoom->from_html($tmpl); + +my @fields; +$z->select('input')->collect({ + into => \@fields, + passthrough => 1, +})->memoize; +is(scalar @fields,2,"correctly extracted all inputs"); + +my $expect; + +($expect = $tmpl) =~ s#name="input_field" />#name="input_field" />
cluck
#; + +is( + $z->select('input[name="input_field"]') + ->add_after(\"
cluck
") + ->to_html, $expect, +"added after void"); + +($expect = $tmpl) =~ s#Input#Input
cluck
#; + +is( + $z->select('input[name="input_field"]') + ->add_before(\"
cluck
") + ->to_html, $expect, +"added before void");