Three new tests in t/action.t, two of them failing
Jakub Narebski [Wed, 12 Jan 2011 18:25:05 +0000 (19:25 +0100)]
All of add_before, add_after and replace methods from
HTML::Zoom::FilterBuilder should accept anything zoom-able, like
e.g. string (to be turned into text element), not only naked events.

Currently $zoom->...->replace("foo") works, but neither
->add_before("foo") nor ->add_after("foo") do.

t/actions.t

index 584ec36..c2bc480 100644 (file)
@@ -101,7 +101,12 @@ my $ohai = [ { type => 'TEXT', raw => 'O HAI' } ];
 is(
   run_for { $_->add_before($ohai) },
   $expect,
-  'add_before ok'
+  'add_before event ok'
+);
+is(
+  eval { run_for { $_->add_before('O HAI') } },
+  $expect,
+  'add_before string ok'
 );
 
 ($expect = $tmpl) =~ s/(?<=<\/div>)/O HAI/;
@@ -109,7 +114,12 @@ is(
 is(
   run_for { $_->add_after($ohai) },
   $expect,
-  'add_after ok'
+  'add_after event ok'
+);
+is(
+  eval { run_for { $_->add_after('O HAI') } },
+  $expect,
+  'add_after string ok'
 );
 
 ($expect = $tmpl) =~ s/(?<=class="main">)/O HAI/;
@@ -128,13 +138,20 @@ is(
   'prepend_content ok with in place close'
 );
 
-is(
-  run_for { $_->replace($ohai) },
-'<body>
+$expect = <<'HTML';
+<body>
   O HAI
 </body>
-',
-  'replace ok'
+HTML
+is(
+  run_for { $_->replace($ohai) },
+  $expect,
+  'replace event ok'
+);
+is(
+  run_for { $_->replace('O HAI') },
+  $expect,
+  'replace string ok'
 );
 
 @ev = ();