9fc9f413ad88b5c0484b9f05f1dd572f20a41a19
[catagits/HTML-Zoom.git] / t / synopsis / filterbuilder.t
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">
21     <p>Well Now</p>
22     <p id="p2">Is the Time</p>
23 </div>
24 BODY
25
26 my $output =  $root
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;
38
39
40 my $expect = <<HTML;
41 <html>
42   <head>
43     <title>Hello World</title>
44   </head>
45   <body class="main"><div id="stuff">
46     <p class="para">Well Now</p>
47     <p id="p2" class="para2">Is the Time</p>
48 </div>
49 </body>
50 </html>
51 HTML
52 is($output, $expect, 'Synopsis code works ok');
53