X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Factions.t;h=d1dcc54d2c2de674f238798ade1755a38c568c9a;hb=071d883153cb8067921eada9946a996b68c70fc7;hp=4e3315be269a8751224db40f4cdcf694d6f6ce9b;hpb=f0ddc273d86f2229d0a20103206ccc7d82078289;p=catagits%2FHTML-Zoom.git diff --git a/t/actions.t b/t/actions.t index 4e3315b..d1dcc54 100644 --- a/t/actions.t +++ b/t/actions.t @@ -9,7 +9,7 @@ use HTML::Zoom::FilterStream; my $tmpl = < -
+
Bob Builder
@@ -55,6 +55,14 @@ is( 'set attribute on existing attribute' ); +($expect = $tmpl) =~ s/name="cow" class="main"/name="bar" class="foo"/; + +is( + run_for { $_->set_attr({ 'class' => 'foo', 'name' => 'bar'}) }, + $expect, + 'set attributes using hashref form (shorthand)' +); + ($expect = $tmpl) =~ s/class="main"/class="main" foo="bar"/; is( @@ -71,6 +79,22 @@ is( 'add attribute on existing attribute' ); +($expect = $tmpl) =~ s/class="main"/class="main foo"/; + +is( + run_for { $_->add_class('foo') }, + $expect, + 'add attribute on existing attribute (shorthand)' +); + +($expect = $tmpl) =~ s/class="main"/class="main" id="foo"/; + +is( + run_for { $_->set_id('foo') }, + $expect, + 'set_id (shorthand)' +); + ($expect = $tmpl) =~ s/class="main"/class="main" foo="bar"/; is( @@ -93,6 +117,28 @@ is( 'remove attribute on non existing attribute' ); +($expect = $tmpl) =~ s/class="main"/class=""/; + +is( + run_for { $_->remove_from_attribute({ class => 'main' }) }, + $expect, + 'remove name from attribute' +); + +is( + run_for { $_->remove_from_attribute({ madeup => 'main' }) }, + $tmpl, + 'remove name from non existing attribute (ignored)' +); + +($expect = $tmpl) =~ s/class="main"/class=""/; + +is( + run_for { $_->remove_class( 'main' ) }, + $expect, + 'remove_class' +); + ($expect = $tmpl) =~ s/ class="main"//; is( @@ -207,7 +253,7 @@ is( is( HTML::Zoom::Producer::BuiltIn->html_from_events(\@ev), - '
+ '
Bob Builder
@@ -220,7 +266,7 @@ is( is( run_for { $_->collect({ into => \@ev, content => 1 }) }, ' -
+
', 'collect w/content removes correctly' @@ -239,7 +285,7 @@ is( is( run_for { $_->replace($ohai, { content => 1 }) }, ' -
O HAI
+
O HAI
', 'replace w/content' @@ -273,11 +319,11 @@ is( ) }, q{ -
+
mst Chainsaw Wielder
-
+
mdk Adminion
@@ -305,7 +351,7 @@ is( ) }, q{ -
+
mst Chainsaw Wielder
@@ -345,7 +391,7 @@ is( ) }, q{ -
+
mst Chainsaw Wielder
@@ -378,7 +424,7 @@ is( ) }, q{ -
+
mst Chainsaw Wielder