Commit | Line | Data |
---|---|---|
0d8f057e | 1 | use strict; |
2 | use warnings FATAL => 'all'; | |
3 | use Test::More qw(no_plan); | |
4 | ||
a42917f6 | 5 | |
6 | ||
0d8f057e | 7 | use HTML::Zoom; |
8 | my $root = HTML::Zoom | |
9 | ->from_html(<<MAIN); | |
10 | <html> | |
11 | <head> | |
12 | <title>Default Title</title> | |
13 | </head> | |
a42917f6 | 14 | <body bad_attr='junk'> |
0d8f057e | 15 | Default Content |
16 | </body> | |
17 | </html> | |
18 | MAIN | |
19 | ||
a42917f6 | 20 | |
21 | ||
22 | $root = $root | |
23 | ->select('body') | |
24 | ->set_attribute(class=>'main'); | |
25 | ||
26 | ||
27 | ||
28 | $root = $root | |
29 | ->select('body') | |
30 | ->add_to_attribute(class=>'one-column'); | |
31 | ||
32 | ||
33 | ||
34 | $root = $root | |
35 | ->select('title') | |
36 | ->replace_content('Hello World'); | |
37 | ||
38 | ||
39 | ||
0d8f057e | 40 | my $body = HTML::Zoom |
41 | ->from_html(<<BODY); | |
42 | <div id="stuff"> | |
adb30a8a | 43 | <p>Well Now</p> |
f8ad684d | 44 | <p id="p2">Is the Time</p> |
0d8f057e | 45 | </div> |
46 | BODY | |
47 | ||
a42917f6 | 48 | $root = $root |
f8ad684d | 49 | ->select('body') |
a42917f6 | 50 | ->replace_content($body); |
51 | ||
52 | ||
53 | ||
54 | $root = $root | |
f8ad684d | 55 | ->select('p') |
a42917f6 | 56 | ->set_attribute(class=>'para'); |
57 | ||
58 | ||
59 | ||
60 | $root = $root | |
61 | ->select('body') | |
62 | ->remove_attribute('bad_attr'); | |
0d8f057e | 63 | |
64 | ||
a42917f6 | 65 | my $output = $root->to_html; |
0d8f057e | 66 | my $expect = <<HTML; |
67 | <html> | |
68 | <head> | |
69 | <title>Hello World</title> | |
70 | </head> | |
a42917f6 | 71 | <body class="main one-column"><div id="stuff"> |
adb30a8a | 72 | <p class="para">Well Now</p> |
a42917f6 | 73 | <p id="p2" class="para">Is the Time</p> |
0d8f057e | 74 | </div> |
75 | </body> | |
76 | </html> | |
77 | HTML | |
78 | is($output, $expect, 'Synopsis code works ok'); | |
79 |