diff options
author | Alan Pearce | 2014-09-20 16:53:16 +0100 |
---|---|---|
committer | Alan Pearce | 2014-09-20 16:53:16 +0100 |
commit | 8eca33a1e4b5aa244a3a11bf1c8f1ed1b47b7e8d (patch) | |
tree | f2588133451ecfa68cadc80ccb1490c0c778145b /test | |
parent | ad7798bf10d8cc64f28a6bcdd1e83e1ae77cc14e (diff) | |
download | microformats-8eca33a1e4b5aa244a3a11bf1c8f1ed1b47b7e8d.tar.lz microformats-8eca33a1e4b5aa244a3a11bf1c8f1ed1b47b7e8d.tar.zst microformats-8eca33a1e4b5aa244a3a11bf1c8f1ed1b47b7e8d.zip |
Extract helper method from tests
Diffstat (limited to 'test')
-rw-r--r-- | test/microformats/parser_expectations.clj | 62 |
1 files 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 "<p class=\"p-name\"><span class=\"value\">Name</span></p>")))) + (parse-p (snippet "<p class=\"p-name\"><span class=\"value\">Name</span></p>"))) (expect {:name "Name Endname"} - (parse-p (first (html-snippet "<p class=\"p-name\"><span class=\"value\">Name</span> (this should not be included) <span class=\"value\">Endname</span></p>")))) + (parse-p (snippet "<p class=\"p-name\"><span class=\"value\">Name</span> (this should not be included) <span class=\"value\">Endname</span></p>"))) (expect {:name "Example User"} - (parse-p (first (html-snippet "<p class=\"p-name\">Example User</p>")))) + (parse-p (snippet "<p class=\"p-name\">Example User</p>"))) (expect {:nickname "exuser"} - (parse-p (first (html-snippet "<p class=\"p-nickname\">exuser</p>")))) + (parse-p (snippet "<p class=\"p-nickname\">exuser</p>"))) (expect {:name "Example User"} - (parse-p (first (html-snippet "<img class=\"p-name\" alt=\"Example User\">")))) + (parse-p (snippet "<img class=\"p-name\" alt=\"Example User\">"))) (expect {:name "Example User"} - (parse-p (first (html-snippet "<abbr class=\"p-name\" title=\"Example User\">@example</abbr>")))) + (parse-p (snippet "<abbr class=\"p-name\" title=\"Example User\">@example</abbr>"))) (expect {:name "@example"} - (parse-p (first (html-snippet "<abbr class=\"p-name\">@example</abbr>")))) + (parse-p (snippet "<abbr class=\"p-name\">@example</abbr>"))) (expect {:name "Example User"} - (parse-p (first (html-snippet "<data class=\"p-name\" value=\"Example User\"></data>")))) + (parse-p (snippet "<data class=\"p-name\" value=\"Example User\"></data>"))) (expect {:name "Example User"} - (parse-p (first (html-snippet "<data class=\"p-name\">Example User</data>")))) + (parse-p (snippet "<data class=\"p-name\">Example User</data>"))) (expect {:name ""} - (parse-p (first (html-snippet "<br class=\"p-name\"/>")))) + (parse-p (snippet "<br class=\"p-name\"/>"))) (expect {:name ""} - (parse-p (first (html-snippet "<hr class=\"p-name\"/>")))) + (parse-p (snippet "<hr class=\"p-name\"/>"))) (expect {:url "http://example.com"} - (parse-u (first (html-snippet "<a class=\"u-url\" href=\"http://example.com\">Awesome example website</a>")))) + (parse-u (snippet "<a class=\"u-url\" href=\"http://example.com\">Awesome example website</a>"))) (expect {:photo "http://example.com/someimage.png"} - (parse-u (first (html-snippet "<img class=\"u-photo\" src=\"http://example.com/someimage.png\">")))) + (parse-u (snippet "<img class=\"u-photo\" src=\"http://example.com/someimage.png\">"))) (expect {:photo "http://example.com/someimage.png"} - (parse-u (first (html-snippet "<area class=\"u-photo\" href=\"http://example.com/someimage.png\"></area>")))) + (parse-u (snippet "<area class=\"u-photo\" href=\"http://example.com/someimage.png\"></area>"))) (expect {:photo "http://example.com/someimage.png"} - (parse-u (first (html-snippet "<object class=\"u-photo\" data=\"http://example.com/someimage.png\"></object>")))) + (parse-u (snippet "<object class=\"u-photo\" data=\"http://example.com/someimage.png\"></object>"))) (expect {:photo "http://example.com/someimage.png"} - (parse-u (first (html-snippet "<abbr class=\"u-photo\" title=\"http://example.com/someimage.png\"></abbr>")))) + (parse-u (snippet "<abbr class=\"u-photo\" title=\"http://example.com/someimage.png\"></abbr>"))) (expect {:photo "http://example.com/someimage.png"} - (parse-u (first (html-snippet "<abbr class=\"u-photo\">http://example.com/someimage.png</abbr>")))) + (parse-u (snippet "<abbr class=\"u-photo\">http://example.com/someimage.png</abbr>"))) (expect {:photo "http://example.com/someimage.png"} - (parse-u (first (html-snippet "<data class=\"u-photo\" value=\"http://example.com/someimage.png\"></data>")))) + (parse-u (snippet "<data class=\"u-photo\" value=\"http://example.com/someimage.png\"></data>"))) (expect {:photo "http://example.com/someimage.png"} - (parse-u (first (html-snippet "<data class=\"u-photo\">http://example.com/someimage.png</data>")))) + (parse-u (snippet "<data class=\"u-photo\">http://example.com/someimage.png</data>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<time class=\"dt-start\" datetime=\"2012-08-05T14:50\"></time>")))) + (parse-dt (snippet "<time class=\"dt-start\" datetime=\"2012-08-05T14:50\"></time>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<time class=\"dt-start\">2012-08-05T14:50</time>")))) + (parse-dt (snippet "<time class=\"dt-start\">2012-08-05T14:50</time>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<ins class=\"dt-start\" datetime=\"2012-08-05T14:50\"></ins>")))) + (parse-dt (snippet "<ins class=\"dt-start\" datetime=\"2012-08-05T14:50\"></ins>"))) (expect {:end "2012-08-05T18:00"} - (parse-dt (first (html-snippet "<del class=\"dt-end\" datetime=\"2012-08-05T18:00\"></del>")))) + (parse-dt (snippet "<del class=\"dt-end\" datetime=\"2012-08-05T18:00\"></del>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<abbr class=\"dt-start\" title=\"2012-08-05T14:50\"></abbr>")))) + (parse-dt (snippet "<abbr class=\"dt-start\" title=\"2012-08-05T14:50\"></abbr>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<abbr class=\"dt-start\">2012-08-05T14:50</abbr>")))) + (parse-dt (snippet "<abbr class=\"dt-start\">2012-08-05T14:50</abbr>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<data class=\"dt-start\" value=\"2012-08-05T14:50\"></data>")))) + (parse-dt (snippet "<data class=\"dt-start\" value=\"2012-08-05T14:50\"></data>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<data class=\"dt-start\">2012-08-05T14:50</data>")))) + (parse-dt (snippet "<data class=\"dt-start\">2012-08-05T14:50</data>"))) (expect {:start "2012-08-05T14:50"} - (parse-dt (first (html-snippet "<input class=\"dt-start\" value=\"2012-08-05T14:50\">")))) + (parse-dt (snippet "<input class=\"dt-start\" value=\"2012-08-05T14:50\">"))) (expect {:content {:html "Here is a load of <strong>embedded markup</strong>" :value "Here is a load of embedded markup"}} - (parse-e (first (html-snippet "<div class=\"e-content\">Here is a load of <strong>embedded markup</strong></div>")))) + (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>"))) |