merge helpers
[catagits/HTML-Zoom.git] / t / dwim-autoload.t
index edf7f38..8765a99 100644 (file)
@@ -100,15 +100,6 @@ like(
 like(
   HTML::Zoom
     ->from_html(q[<p class="first">Hi!</p>])
-    ->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[<p class="first">Hi!</p>])
     ->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[<p class="first">Hi!</p>])
-    ->set_attribute('p', {name => 'class', value => 'para'})
-    ->to_html,
-  qr/class="para"/,
-  'Got correct from set_attribute'
-);
-
 is(
   HTML::Zoom
     ->from_html(q[<p class="first">Hi!</p>])
@@ -360,4 +342,20 @@ sub code_stream (&) {
     'Hashref selectors on codestream';
 }
 
+{
+  ok my $dwim = HTML::Zoom
+  ->from_html(q[<ul><li class="foo" name="bar"></li><li class="bar"></li></ul>])
+  ->select('ul')->collect({ 
+  passthrough => 1,
+  filter => sub {
+      $_->set_attribute({
+        'li.foo' => [{ class => 'baz', name => 'moo', }],
+        'li.bar' => [ class => 'qux' ],
+      });
+    }
+  })->to_html;
+  is $dwim, '<ul><li class="baz" name="moo"></li><li class="qux"></li></ul>',
+    'Hashref selectors with hashref attributes on codestream';
+}
+
 done_testing;