diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/microformats/parser_expectations.clj | 107 |
1 files changed, 56 insertions, 51 deletions
diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj index b22e3a9..1c6d4f1 100644 --- a/test/microformats/parser_expectations.clj +++ b/test/microformats/parser_expectations.clj @@ -27,14 +27,19 @@ (expect '({:tag :div :attrs {:class "h-card"} :content nil}) - (select-h (z/xml-zip (html-snippet - "<div class=\"h-card\"></div>")))) + (map-h identity (z/xml-zip (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>")))) (expect '({:tag :div :attrs {:class "h-card"} :content ({:tag :a :attrs {:class "h-org"} :content nil})}) - (select-h (z/xml-zip (html-snippet - "<div class=\"h-card\"><a class=\"h-org\"></a></div>")))) + (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" @@ -42,7 +47,7 @@ :content ({:tag :a :attrs {:class "h-org"} :content nil})} "\n")}) - (select-h (z/xml-zip (html-snippet "<div class=\"h-card\"> + (map-h identity (z/xml-zip (snippet "<div class=\"h-card\"> <p><a class=\"h-org\"></a></p> </div>")))) @@ -136,77 +141,77 @@ (expect {:content '({:html "Here is a load of <strong>embedded markup</strong>" :value "Here is a load of embedded markup"})} (parse-e (snippet "<div class=\"e-content\">Here is a load of <strong>embedded markup</strong></div>"))) -(expect {:author ["http://example.com/a"]} +(expect {:author '("http://example.com/a")} (parse-rels (html-snippet "<a rel=\"author\" href=\"http://example.com/a\">author a</a>"))) -(expect {:author ["http://example.com/a" "http://example.com/b"]} +(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> <a rel=\"author\" href=\"http://example.com/b\">author b</a>"))) -(expect {:items [] :rels {}} +(expect {:items nil :rels {}} (parse "")) -(expect {:items [{:properties {:name '("Example User")} :type ["h-card"]}] :rels {}} +(expect {:items '({:properties {:name ("Example User")} :type ("h-card")}) :rels {}} (parse "<div class=\"h-card\"><p class=\"p-name\">Example User</p></div>")) -(expect {:items [{:properties {:name '("Example User")} :type ["h-card"]}] :rels {}} +(expect {:items '({:properties {:name ("Example User")} :type ("h-card")}) :rels {}} (parse "<div class=\"h-card\"><p class=\"p-name\"> Example User </p></div>")) -(expect {:items [{:properties {:name '("Example User")} :type ["h-card"]}] :rels {}} +(expect {:items '({:properties {:name ("Example User")} :type ("h-card")}) :rels {}} (parse " <div class=\"h-card\"><p class=\"p-name\">Example User</p></div>")) -(expect {:items [{:properties {:name '("Example User") :url '("http://example.com")} - :type ["h-card"]}] :rels {}} +(expect {:items '({:properties {:name ("Example User") :url ("http://example.com")} + :type ("h-card")}) :rels {}} (parse "<div class=\"h-card\"><a class=\"p-name u-url\" href=\"http://example.com\">Example User</></div>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User")}}) :rels {}} (parse "<p class=\"h-card\">Example User</p>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User") :url '("http://example.com")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User") :url ("http://example.com")}}) :rels {}} (parse "<a class=\"h-card\" href=\"http://example.com\">Example User</a>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User") - :photo '("http://example.com/me.png")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User") + :photo ("http://example.com/me.png")}}) :rels {}} (parse "<img class=\"h-card\" alt=\"Example User\" src=\"http://example.com/me.png\"></img>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User")}}) :rels {}} (parse "<abbr class=\"h-card\" title=\"Example User\">Incorrect</abbr>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User")}}) :rels {}} (parse "<p class=\"h-card\"><img alt=\"Example User\"></p>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User")}}) :rels {}} (parse "<p class=\"h-card\"><abbr title=\"Example User\">Wrong </abbr></p>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User")}}) :rels {}} (parse "<div class=\"h-card\"><div><img alt=\"Example User\"></div></div>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User")}}) :rels {}} (parse "<div class=\"h-card\"><p><abbr title=\"Example User\">Wrong</abbr></p></div>")) -(expect {:items [{:type ["h-card"] :properties {:photo '("http://example.com/me.png")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:photo ("http://example.com/me.png")}}) :rels {}} (parse "<object class=\"h-card\" data=\"http://example.com/me.png\"></object>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User") - :photo '("http://example.com/me.png")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User") + :photo ("http://example.com/me.png")}}) :rels {}} (parse "<div class=\"h-card\"><img alt=\"Example User\" src=\"http://example.com/me.png\"></div>")) -(expect {:items [{:type ["h-card"] :properties {:photo '("http://example.com/me.png")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:photo ("http://example.com/me.png")}}) :rels {}} (parse "<div class=\"h-card\"><object data=\"http://example.com/me.png\"></object></div>")) -(expect {:items [{:type ["h-card"] :properties {:photo '("http://example.com/me.png")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:photo ("http://example.com/me.png")}}) :rels {}} (parse "<div class=\"h-card\"><div><object data=\"http://example.com/me.png\"></object></div></div>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User") - :photo '("http://example.com/me.png")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User") + :photo ("http://example.com/me.png")}}) :rels {}} (parse "<div class=\"h-card\"><div><img alt=\"Example User\" src=\"http://example.com/me.png\"></div></div>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example User") :url '("http://example.com")}}] :rels {}} +(expect {:items '({:type ("h-card") :properties {:name ("Example User") :url ("http://example.com")}}) :rels {}} (parse "<div class=\"h-card\"><a href=\"http://example.com\">Example User</a></div>")) -(expect {:items [{:type ["h-card"] :properties {:name '("Example") - :url '("http://example.com" - "http://myblog.com")}}] +(expect {:items '({:type ("h-card") :properties {:name ("Example") + :url ("http://example.com" + "http://myblog.com")}}) :rels {}} (parse "<div class=\"h-card\"> <p class=\"u-name\">Example</p> @@ -214,9 +219,9 @@ <a class=\"u-url\" href=\"http://myblog.com\">My Blog</a> </div>")) -(expect {:items [{:type ["h-card"] - :properties {:name '("Example") - :tel '("01234567890")}}] +(expect {:items '({:type ("h-card") + :properties {:name ("Example") + :tel ("01234567890")}}) :rels {}} (parse "<div class=\"h-card\"> <p class=\"p-name\">Example</p> @@ -225,14 +230,14 @@ </div>")) (expect - {:items [{:type ["h-adr"], - :properties {:street-address '("665 3rd St."), - :extended-address '("Suite 207"), - :locality '("San Francisco"), - :region '("CA"), - :postal-code '("94107"), - :country-name '("U.S.A."), - :name '("665 3rd St. Suite 207 San Francisco, CA 94107 U.S.A.")}}] + {:items '({:type ("h-adr"), + :properties {:street-address ("665 3rd St."), + :extended-address ("Suite 207"), + :locality ("San Francisco"), + :region ("CA"), + :postal-code ("94107"), + :country-name ("U.S.A."), + :name ("665 3rd St. Suite 207 San Francisco, CA 94107 U.S.A.")}}) :rels {}} (parse "<p class=\"h-adr\"> <span class=\"p-street-address\">665 3rd St.</span> @@ -243,16 +248,16 @@ <span class=\"p-country-name\">U.S.A.</span> </p>")) -(expect {:items [{:type ["h-card" "h-org"] - :properties {:name '("Example")}}] +(expect {:items '({:type ("h-card" "h-org") + :properties {:name ("Example")}}) :rels {}} (parse "<p class=\"h-card h-org\">Example</p>")) -(expect {:items [{:type ["h-card"] - :properties {:name '("John Doe") - :org '({:value "Example" - :type ["h-card" "h-org"] - :properties {:name ("Example")}})}}] +(expect {:items '({:type ("h-card") + :properties {:name ("John Doe") + :org ({:value "Example" + :type ("h-card" "h-org") + :properties {:name ("Example")}})}}) :rels {}} (parse "<div class=\"h-card\"> <span class=\"p-name\">John Doe</span> |