about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/microformats/parser_expectations.clj42
1 files changed, 23 insertions, 19 deletions
diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj
index 0e72e10..6ce942e 100644
--- a/test/microformats/parser_expectations.clj
+++ b/test/microformats/parser_expectations.clj
@@ -4,9 +4,13 @@
             [clojure.zip :as z]
             [net.cgrand.enlive-html :refer [html-snippet]]))
 
+(defn- snippets
+  [html]
+  (map z/xml-zip (html-snippet html)))
+
 (defn- snippet
   [html]
-  (first (html-snippet html)))
+  (first (snippets html)))
 
 (expect [:location]
         (into [] ((classes-to-props "p-") ["someclass" "p-location" "someotherclass"])))
@@ -22,34 +26,34 @@
 <span class=\"p-street-address\">665 3rd St.</span>
 <span class=\"p-extended-address\">Suite 207</span>
 </p>"
-             snippet :content
+             snippet z/node :content
              (#'microformats.parser/node-to-text)))
 
 (expect '({:tag :div :attrs {:class "h-card"}
            :content nil})
-        (map-h identity (z/xml-zip (snippet
-                                    "<div class=\"h-card\"></div>"))))
+        (map-h z/node (snippet
+                       "<div class=\"h-card\"></div>")))
 
 (expect '({:tag :div :attrs {:class "h-card"}
            :content nil})
-        (map-h identity (z/xml-zip (snippet
-                                    "<header><div class=\"h-card\"></div></header>"))))
+        (map-h z/node (snippet
+                       "<header><div class=\"h-card\"></div></header>")))
 
 (expect '({:tag :div :attrs {:class "h-card"}
            :content ({:tag :a :attrs {:class "h-org"}
                       :content nil})})
-        (map-h identity (z/xml-zip (snippet
-                                    "<div class=\"h-card\"><a class=\"h-org\"></a></div>"))))
-
-(expect '({:tag :div :attrs {:class "h-card"}
-           :content ("\n"
-                     {:tag :p :attrs nil
-                      :content ({:tag :a :attrs {:class "h-org"}
-                                 :content nil})}
-                     "\n")})
-        (map-h identity (z/xml-zip (snippet "<div class=\"h-card\">
+        (map-h z/node (snippet
+                       "<div class=\"h-card\"><a class=\"h-org\"></a></div>")))
+
+(expect {:tag :div :attrs {:class "h-card"}
+                 :content ["\n"
+                           {:tag :p :attrs nil
+                            :content [{:tag :a :attrs {:class "h-org"}
+                                       :content nil}]}
+                           "\n"]}
+                (z/node (snippet "<div class=\"h-card\">
 <p><a class=\"h-org\"></a></p>
-</div>"))))
+</div>")))
 
 (expect "http://example.com"
         (get-base-url (snippet "<head><base href=\"http://example.com\"></head>")))
@@ -151,10 +155,10 @@
         (parse-e (snippet "<div class=\"e-content\">Here is a load of <strong>embedded markup</strong></div>")))
 
 (expect {:author '("http://example.com/a")}
-        (parse-rels (html-snippet "<a rel=\"author\" href=\"http://example.com/a\">author a</a>")))
+        (parse-rels (snippets "<a rel=\"author\" href=\"http://example.com/a\">author a</a>")))
 
 (expect {:author '("http://example.com/a" "http://example.com/b")}
-        (parse-rels (html-snippet "<a rel=\"author\" href=\"http://example.com/a\">author a</a>
+        (parse-rels (snippets "<a rel=\"author\" href=\"http://example.com/a\">author a</a>
 <a rel=\"author\" href=\"http://example.com/b\">author b</a>")))
 
 (expect {:items nil :rels {}}