From: Arthur Axel 'fREW' Schmidt Date: Thu, 27 May 2010 15:19:50 +0000 (-0500) Subject: Commit tests X-Git-Tag: release_0.009004~55 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=3de6bc4440a5c081930d9a4c5762016d24395ada Commit tests --- diff --git a/t/selectors.t b/t/selectors.t new file mode 100644 index 0000000..01e11cf --- /dev/null +++ b/t/selectors.t @@ -0,0 +1,88 @@ +use strict; +#use warnings FATAL => 'all'; +use Test::More; + +use HTML::Zoom; + +# el#id +is( HTML::Zoom->from_html('
') + ->select('div#yo') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E#id works' ); + +# el.class1 +is( HTML::Zoom->from_html('
') + ->select('div.yo') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E.class works' ); + +# el[attr] +is( HTML::Zoom->from_html('
') + ->select('div[frew]') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E[attr] works' ); + +# el[attr="foo"] +is( HTML::Zoom->from_html('
') + ->select('div[frew="yo"]') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E[attr="val"] works' ); + +# el[attr*="foo"] +is( HTML::Zoom->from_html('
') + ->select('div[f*="oo"]') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E[attr*="val"] works' ); + +# el[attr^="foo"] +is( HTML::Zoom->from_html('
') + ->select('div[f^="foo"]') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E[attr^="val"] works' ); + +# el[attr$="foo"] +is( HTML::Zoom->from_html('
') + ->select('div[f$="bar"]') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E[attr$="val"] works' ); + +# el[attr*="foo"] +is( HTML::Zoom->from_html('
') + ->select('div[f*="bar"]') + ->replace_content('grg') + ->to_html, + '
grg
', + 'E[attr*="val"] works' ); + +# sel1 sel2 +is( HTML::Zoom->from_html('
') + ->select('table tr') + ->replace_content(\'') + ->to_html, + '
', + 'sel1 sel2 works' ); + + +# sel1 sel2 sel3 +is( HTML::Zoom->from_html('
') + ->select('table tr td') + ->replace_content('frew') + ->to_html, + '
frew
frew
', + 'sel1 sel2 sel3 works' ); + +done_testing;