Commit | Line | Data |
0d8f057e |
1 | use strict; |
2 | use warnings FATAL => 'all'; |
3 | use Test::More qw(no_plan); |
4 | |
5 | use HTML::Zoom; |
6 | my $root = HTML::Zoom |
7 | ->from_html(<<MAIN); |
8 | <html> |
9 | <head> |
10 | <title>Default Title</title> |
11 | </head> |
12 | <body> |
13 | Default Content |
14 | </body> |
15 | </html> |
16 | MAIN |
17 | |
18 | my $body = HTML::Zoom |
19 | ->from_html(<<BODY); |
20 | <div id="stuff"> |
adb30a8a |
21 | <p>Well Now</p> |
f8ad684d |
22 | <p id="p2">Is the Time</p> |
0d8f057e |
23 | </div> |
24 | BODY |
25 | |
26 | my $output = $root |
f8ad684d |
27 | ->select('title') |
28 | ->replace_content('Hello World') |
29 | ->select('body') |
30 | ->replace_content($body) |
31 | ->then |
32 | ->set_attribute(class=>'main') |
33 | ->select('p') |
34 | ->set_attribute(class=>'para') |
35 | ->select('#p2') |
36 | ->set_attribute(class=>'para2') |
37 | ->to_html; |
0d8f057e |
38 | |
39 | |
40 | my $expect = <<HTML; |
41 | <html> |
42 | <head> |
43 | <title>Hello World</title> |
44 | </head> |
f8ad684d |
45 | <body class="main"><div id="stuff"> |
adb30a8a |
46 | <p class="para">Well Now</p> |
f8ad684d |
47 | <p id="p2" class="para2">Is the Time</p> |
0d8f057e |
48 | </div> |
49 | </body> |
50 | </html> |
51 | HTML |
52 | is($output, $expect, 'Synopsis code works ok'); |
53 | |