Added test to demonstrate bug
[catagits/HTML-Zoom.git] / t / bugs / repeat_replace_on_empty_tag.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use HTML::Zoom;
9
10 my $tmpla = <<END;
11 <body>
12   <div class="main"></div>
13 </body>
14 END
15
16
17 my $tmplb = <<END;
18 <body>
19   <div class="main" />
20 </body>
21 END
22
23 my $ra = HTML::Zoom->from_html( $tmpla )->select('.main')->repeat( [
24     sub{
25         $_->select('div')->replace_content('foo');
26     }
27 ])->to_html;
28
29 like( $ra, qr^<div class="main">foo</div>^ );
30
31
32 my $rb = HTML::Zoom->from_html( $tmplb )->select('.main')->repeat( [
33     sub{
34         $_->select('div')->replace_content('foo');
35     }
36 ])->to_html;
37
38 like( $rb, qr^<div class="main">foo</div>^);
39
40 done_testing;