X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fselectors.t;h=c8b5b11630c01bdd2016f26ba6d4d2cbd2e9ebe1;hb=5bfa7aeb8328819f71cc7b3603a195a943e27b45;hp=e6be2c229704013e613a8d3cac6a110797d3d8e6;hpb=24725e7b32b680b376c06b1f9d641ec11fc1d067;p=catagits%2FHTML-Zoom.git
diff --git a/t/selectors.t b/t/selectors.t
index e6be2c2..c8b5b11 100644
--- a/t/selectors.t
+++ b/t/selectors.t
@@ -1,5 +1,4 @@
-use strict;
-#use warnings FATAL => 'all';
+use strictures 1;
use Test::More;
use HTML::Zoom;
@@ -32,6 +31,15 @@ is( HTML::Zoom->from_html('
'.$stub)
'grg
'.$stub,
'E.class works' );
+
+# el.class\.1
+is( HTML::Zoom->from_html(''.$stub)
+ ->select('div.yo\.yo')
+ ->replace_content('grg')
+ ->to_html,
+ 'grg
'.$stub,
+ 'E.class\.0 works' );
+
# el[attr]
is( HTML::Zoom->from_html(''.$stub)
->select('div[frew]')
@@ -40,6 +48,14 @@ is( HTML::Zoom->from_html(''.$stub)
'grg
'.$stub,
'E[attr] works' );
+# *[attr]
+is( HTML::Zoom->from_html(''.$stub)
+ ->select('*[frew]')
+ ->replace_content('grg')
+ ->to_html,
+ 'grg
grg'.$stub,
+ '*[attr] works' );
+
# el[attr="foo"]
is( HTML::Zoom->from_html(''.$stub)
->select('div[frew="yo"]')
@@ -56,6 +72,25 @@ is( HTML::Zoom->from_html(''.$stub)
'grg
'.$stub,
'E[attr=val] works' );
+{
+ local $TODO = 'mixed-case attribute names are broken';
+ # el[Attr=foo]
+ is( HTML::Zoom->from_html(''.$stub)
+ ->select('div[FreW=yo]')
+ ->replace_content('grg')
+ ->to_html,
+ 'grg
'.$stub,
+ 'E[attr=val] works with mixed-case attribute names' );
+}
+
+# el[attr=foo\.bar]
+is( HTML::Zoom->from_html(''.$stub)
+ ->select('div[frew=yo\.yo]')
+ ->replace_content('grg')
+ ->to_html,
+ 'grg
'.$stub,
+ 'E[attr=foo\.bar] works' );
+
# el[attr!="foo"]
is( HTML::Zoom->from_html(''.$stub)
->select('div[class!="waargh"]')
@@ -104,6 +139,16 @@ is( HTML::Zoom->from_html(''.$stub)
'grg
'.$stub,
'E[attr~="val"] works' );
+# el[attr|="foo"]
+is( HTML::Zoom->from_html(''.
+ ''.$stub)
+ ->select('div[lang|="en"]')
+ ->replace_content('grg')
+ ->to_html,
+ ''.
+ 'grg
grg
'.$stub,
+ 'E[attr|="val"] works' );
+
# [attr=bar]
ok( check_select( '[prop=moo]'), '[attr=bar]' );