X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fdwim-autoload.t;h=8765a995a9689820c019214e6fb57febb2b529fc;hb=14e73b8419d34f1501e47bc74a298df092cebdb5;hp=caf77167de4cb10a0792e487a6308aa391536c84;hpb=f0ddc273d86f2229d0a20103206ccc7d82078289;p=catagits%2FHTML-Zoom.git diff --git a/t/dwim-autoload.t b/t/dwim-autoload.t index caf7716..8765a99 100644 --- a/t/dwim-autoload.t +++ b/t/dwim-autoload.t @@ -304,4 +304,58 @@ sub code_stream (&) { 'Got correct from repeat_content'; } +{ + ok my $dwim = HTML::Zoom + ->from_html(q[]) + ->replace_content({ + 'li.foo' => ['foo'], + 'li.bar' => ['bar'], + })->to_html; + is $dwim, '', + 'Hashref selectors (via replace_content)'; +} + +{ + ok my $dwim = HTML::Zoom + ->from_html(q[]) + ->set_attribute({ + 'li.foo' => [ class => 'baz' ], + 'li.bar' => [ class => 'qux' ], + })->to_html; + is $dwim, '', + '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;