(ns microformats.parser-expectations (:require [expectations :refer :all] [microformats.parser :refer :all] [net.cgrand.enlive-html :refer [html-snippet]])) (expect [:location] (into [] ((classes-to-props "p-") ["someclass" "p-location" "someotherclass"]))) (expect [:location :name] (into [] ((classes-to-props "p-") ["someclass" "p-location" "someotherclass" "p-name"]))) (expect "Foo bar" (apply str (#'microformats.parser/node-to-html '("Foo " {:tag :strong, :attrs nil, :content ("bar")})))) (expect {:name "Example User"} (parse-p (first (html-snippet "

Example User

")))) (expect {:nickname "exuser"} (parse-p (first (html-snippet "

exuser

")))) (expect {:name "Example User"} (parse-p (first (html-snippet "\"Example")))) (expect {:name "Example User"} (parse-p (first (html-snippet "@example")))) (expect {:name "@example"} (parse-p (first (html-snippet "@example")))) (expect {:name "Example User"} (parse-p (first (html-snippet "")))) (expect {:name "Example User"} (parse-p (first (html-snippet "Example User")))) (expect {:name ""} (parse-p (first (html-snippet "
")))) (expect {:name ""} (parse-p (first (html-snippet "
")))) (expect {:url "http://example.com"} (parse-u (first (html-snippet "Awesome example website")))) (expect {:photo "http://example.com/someimage.png"} (parse-u (first (html-snippet "")))) (expect {:photo "http://example.com/someimage.png"} (parse-u (first (html-snippet "")))) (expect {:photo "http://example.com/someimage.png"} (parse-u (first (html-snippet "")))) (expect {:photo "http://example.com/someimage.png"} (parse-u (first (html-snippet "")))) (expect {:photo "http://example.com/someimage.png"} (parse-u (first (html-snippet "http://example.com/someimage.png")))) (expect {:photo "http://example.com/someimage.png"} (parse-u (first (html-snippet "")))) (expect {:photo "http://example.com/someimage.png"} (parse-u (first (html-snippet "http://example.com/someimage.png")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "")))) (expect {:end "2012-08-05T18:00"} (parse-dt (first (html-snippet "")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "2012-08-05T14:50")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "2012-08-05T14:50")))) (expect {:start "2012-08-05T14:50"} (parse-dt (first (html-snippet "")))) (expect {:content {:html "Here is a load of embedded markup" :value "Here is a load of embedded markup"}} (parse-e (first (html-snippet "
Here is a load of embedded markup
")))) (expect {:author ["http://example.com/a"]} (parse-rels (html-snippet "author a"))) (expect {:author ["http://example.com/a" "http://example.com/b"]} (parse-rels (html-snippet "author a author b")))