X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fdwim-autoload.t;h=8765a995a9689820c019214e6fb57febb2b529fc;hb=bce61371d913754688d91e7a325f45b7bc7e6f1e;hp=405543e5b1c8987ed59162d67eb00b51f464b285;hpb=efc6c054d3681e579364e270c16f512f3645ef31;p=catagits%2FHTML-Zoom.git diff --git a/t/dwim-autoload.t b/t/dwim-autoload.t index 405543e..8765a99 100644 --- a/t/dwim-autoload.t +++ b/t/dwim-autoload.t @@ -100,15 +100,6 @@ like( like( HTML::Zoom ->from_html(q[

Hi!

]) - ->add_to_attribute('p', {name => 'class', value => 'para'}) - ->to_html, - qr/first para/, - 'Got correct from add_to_attribute' -); - -like( - HTML::Zoom - ->from_html(q[

Hi!

]) ->add_to_attribute('p', class => 'para') ->to_html, qr/first para/, @@ -124,15 +115,6 @@ like( 'Got correct from set_attribute' ); -like( - HTML::Zoom - ->from_html(q[

Hi!

]) - ->set_attribute('p', {name => 'class', value => 'para'}) - ->to_html, - qr/class="para"/, - 'Got correct from set_attribute' -); - is( HTML::Zoom ->from_html(q[

Hi!

]) @@ -330,7 +312,7 @@ sub code_stream (&) { 'li.bar' => ['bar'], })->to_html; is $dwim, '', - 'Multiple selectors from hashref (via replace_content)'; + 'Hashref selectors (via replace_content)'; } { @@ -341,7 +323,39 @@ sub code_stream (&) { 'li.bar' => [ class => 'qux' ], })->to_html; is $dwim, '', - 'Multiple selectors from hashref (via set_attribute)'; + 'Hashref selectors (via set_attribute)'; +} + +{ + ok my $dwim = HTML::Zoom + ->from_html(q[]) + ->select('ul')->collect({ + passthrough => 1, + filter => sub { + $_->set_attribute({ + 'li.foo' => [ class => 'baz' ], + 'li.bar' => [ class => 'qux' ], + }); + } + })->to_html; + is $dwim, '', + 'Hashref selectors on codestream'; +} + +{ + ok my $dwim = HTML::Zoom + ->from_html(q[]) + ->select('ul')->collect({ + passthrough => 1, + filter => sub { + $_->set_attribute({ + 'li.foo' => [{ class => 'baz', name => 'moo', }], + 'li.bar' => [ class => 'qux' ], + }); + } + })->to_html; + is $dwim, '', + 'Hashref selectors with hashref attributes on codestream'; } done_testing;