Add support for [attr~="value"] selector (attribute contains word)
[catagits/HTML-Zoom.git] / t / selectors.t
index 46e8439..13a8154 100644 (file)
@@ -89,6 +89,14 @@ is( HTML::Zoom->from_html('<div f="foo bar"></div>'.$stub)
    '<div f="foo bar">grg</div>'.$stub,
    'E[attr*="val"] works' );
 
+# el[attr~="foo"]
+is( HTML::Zoom->from_html('<div frew="foo bar baz"></div>'.$stub)
+   ->select('div[frew~="bar"]')
+      ->replace_content('grg')
+   ->to_html,
+   '<div frew="foo bar baz">grg</div>'.$stub,
+   'E[attr~="val"] works' );
+
 # [attr=bar]
 ok( check_select( '[prop=moo]'), '[attr=bar]' );
 
@@ -96,18 +104,16 @@ ok( check_select( '[prop=moo]'), '[attr=bar]' );
 is( check_select('span[class=career],[prop=moo]'), 2,
     'Multiple selectors: el[attr=bar],[attr=foo]');
 
-TODO:{
-    local $TODO = 'Fix selector error messages';
-    # selector parse error test:
-    eval{
-        HTML::Zoom->from_html('<span att="bar"></span>')
-          ->select('[att=bar')
-          ->replace_content('cats')
+
+# selector parse error test:
+eval{
+    HTML::Zoom->from_html('<span att="bar"></span>')
+      ->select('[att=bar')
+      ->replace_content('cats')
           ->to_html;
-    };
-    like( $@, qr/Error parsing dispatch specification/,
-          'Malformed attribute selector results in a helpful error' );
 };
+like( $@, qr/Error parsing dispatch specification/,
+      'Malformed attribute selector ([att=bar) results in a helpful error' );
 
 =pod