Commit | Line | Data |
c877066a |
1 | use strict; |
2 | use warnings FATAL => 'all'; |
3 | |
4 | use HTML::Zoom; |
5 | use Test::More; |
6 | |
7 | ok my $zoom = HTML::Zoom->from_html(<<HTML); |
8 | <html> |
9 | <head> |
10 | <title>Hi!</title> |
11 | </head> |
12 | <body id="content-area"> |
13 | <h1>Test</h1> |
14 | <div> |
15 | <p class="first-para">Some Stuff</p> |
16 | <p class="body-para">More Stuff</p> |
17 | <p class="body-para">Even More Stuff</p> |
18 | <ol> |
19 | <li class="first-item odd">First</li> |
20 | <li class="body-items even">Stuff A</li> |
21 | <li class="body-items odd">Stuff B</li> |
22 | <li class="body-items even">Stuff C</li> |
23 | <li class="last-item odd">Last</li> |
24 | </ol> |
c2d0669e |
25 | <ul class="items"> |
26 | <li>space</li> |
27 | </ul> |
c877066a |
28 | <p class="body-para">Even More stuff</p> |
29 | <p class="last-para">Some Stuff</p> |
30 | </div> |
31 | <p id="footer">Copyright 2222</p> |
32 | </body> |
33 | </html> |
34 | HTML |
35 | |
c877066a |
36 | ok ! eval { $zoom->ressplace_content('.first-param' => 'First!'); 1}, |
37 | 'Properly die on bad method'; |
38 | |
39 | ok my $html = $zoom |
40 | ->replace_content('.first-para' => 'First!') |
41 | ->replace_content('.last-para' => 'Last!') |
42 | ->prepend_content( |
43 | '.first-item' => [{type=>'TEXT', raw=>'FIRST: '}], |
44 | '.last-item' => [{type=>'TEXT', raw=>'LAST: '}], |
45 | ) |
c2d0669e |
46 | ->fill('.odd' => 'IS ODD') |
47 | ->fill('.items' => [ |
48 | sub { $_->select('li')->replace_content("XXX")}, |
49 | sub { $_->select('li')->replace_content("YYY")}, |
3f03e15a |
50 | sub { $_->select('li')->replace_content("ZZZ", "000")}, |
c2d0669e |
51 | ]) |
c877066a |
52 | ->to_html; |
53 | |
54 | warn $html; |
55 | |
c877066a |
56 | done_testing; |