From 8eca33a1e4b5aa244a3a11bf1c8f1ed1b47b7e8d Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 20 Sep 2014 16:53:16 +0100 Subject: Extract helper method from tests --- test/microformats/parser_expectations.clj | 62 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj index 9c8ce1d..5557033 100644 --- a/test/microformats/parser_expectations.clj +++ b/test/microformats/parser_expectations.clj @@ -3,6 +3,10 @@ [microformats.parser :refer :all] [net.cgrand.enlive-html :refer [html-snippet]])) +(defn- snippet + [html] + (first (html-snippet html))) + (expect [:location] (into [] ((classes-to-props "p-") ["someclass" "p-location" "someotherclass"]))) @@ -13,91 +17,91 @@ (apply str (#'microformats.parser/node-to-html '("Foo " {:tag :strong, :attrs nil, :content ("bar")})))) (expect {:name "Name"} - (parse-p (first (html-snippet "

Name

")))) + (parse-p (snippet "

Name

"))) (expect {:name "Name Endname"} - (parse-p (first (html-snippet "

Name (this should not be included) Endname

")))) + (parse-p (snippet "

Name (this should not be included) Endname

"))) (expect {:name "Example User"} - (parse-p (first (html-snippet "

Example User

")))) + (parse-p (snippet "

Example User

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

exuser

")))) + (parse-p (snippet "

exuser

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