added more docs
[catagits/HTML-Zoom.git] / t / synopsis / filterbuilder.t
CommitLineData
0d8f057e 1use strict;
2use warnings FATAL => 'all';
3use Test::More qw(no_plan);
4
5use HTML::Zoom;
6my $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>
16MAIN
17
18my $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>
24BODY
25
26my $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')
434a11c8 33 ->then
34 ->add_to_attribute(class=>'one-column')
35 ->then
36 ->set_attribute(id=>'top')
37 ->then
38 ->add_to_attribute(id=>'deleteme')
39 ->then
40 ->remove_attribute({name=>'id', value=>'deleteme'})
f8ad684d 41 ->select('p')
42 ->set_attribute(class=>'para')
43 ->select('#p2')
44 ->set_attribute(class=>'para2')
45 ->to_html;
0d8f057e 46
47
48my $expect = <<HTML;
49<html>
50 <head>
51 <title>Hello World</title>
52 </head>
434a11c8 53 <body class="main one-column" id="top"><div id="stuff">
adb30a8a 54 <p class="para">Well Now</p>
f8ad684d 55 <p id="p2" class="para2">Is the Time</p>
0d8f057e 56</div>
57</body>
58</html>
59HTML
60is($output, $expect, 'Synopsis code works ok');
61