"$zoom->$whatever($selector => @args)" ==> $zoom->select($selector)->$whatever(...
[catagits/HTML-Zoom.git] / t / dwim-autoload.t
CommitLineData
c877066a 1use strict;
2use warnings FATAL => 'all';
3
4use HTML::Zoom;
5use Test::More;
6
7ok 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>
25 <p class="body-para">Even More stuff</p>
26 <p class="last-para">Some Stuff</p>
27 </div>
28 <p id="footer">Copyright 2222</p>
29 </body>
30</html>
31HTML
32
33## mst: well I'm thinking if basically
34## mst: $zoom->$whatever($selector => @args)
35## mst: becomes $zoom->select($selector)->$whatever(@args)
36
37ok ! eval { $zoom->ressplace_content('.first-param' => 'First!'); 1},
38 'Properly die on bad method';
39
40ok my $html = $zoom
41 ->replace_content('.first-para' => 'First!')
42 ->replace_content('.last-para' => 'Last!')
43 ->prepend_content(
44 '.first-item' => [{type=>'TEXT', raw=>'FIRST: '}],
45 '.last-item' => [{type=>'TEXT', raw=>'LAST: '}],
46 )
47 ->to_html;
48
49warn $html;
50
51#warn $zoom->select('.last-item')->prepend_content([{type=>'TEXT', raw=>'ddd'}])->to_html;
52#warn $zoom->select('.last-item')->prepend_content(\'ddd')->to_html;
53
54done_testing;