Commit | Line | Data |
fdb039c6 |
1 | use strict; |
2 | use warnings FATAL => 'all'; |
3 | use Test::More 'no_plan'; |
4 | |
5 | use HTML::Zoom; |
6 | |
7 | my $template = <<HTML; |
8 | <html> |
9 | <body></body> |
10 | </html> |
11 | HTML |
12 | |
13 | my $expect = <<HTML; |
14 | <html> |
15 | <body>Hello</body> |
16 | </html> |
17 | HTML |
18 | |
19 | my $output = HTML::Zoom |
20 | ->from_html($template) |
21 | ->apply_if(1, sub { $_->select('body')->replace_content('Hello') }) |
22 | ->to_html; |
23 | |
24 | is( $output => $expect, 'apply_if with a true predicate' ); |
25 | |
26 | $output = HTML::Zoom |
27 | ->from_html($template) |
28 | ->apply_if(0, sub { $_->select('body')->replace_content('Hello') }) |
29 | ->to_html; |
30 | |
31 | is( $output => $template, 'apply_if with a false predicate' ); |