From 5955c420a37fdb57eeeeb04c0f649b9d922f7fde Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Sat, 13 Sep 2014 09:27:10 +0100
Subject: Test smaller units of code
---
test/microformats/parser_test.clj | 63 ++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/test/microformats/parser_test.clj b/test/microformats/parser_test.clj
index 26cb094..57bb9d2 100644
--- a/test/microformats/parser_test.clj
+++ b/test/microformats/parser_test.clj
@@ -1,6 +1,7 @@
(ns microformats.parser-test
(:require [clojure.test :refer :all]
- [microformats.parser :refer :all]))
+ [microformats.parser :refer :all]
+ [net.cgrand.enlive-html :refer [html-snippet]]))
(deftest empty-document
(testing "Empty HTML document should return an empty 'items' array and 'rels' hash."
@@ -9,51 +10,51 @@
(deftest parse-p-inner-text
(testing "Inner text of a p- property should be parsed")
- (are [ex in] (= ex (parse in))
- {:items [{:properties {:name "Example User"}}] :rels {}}
- "
"
+ (are [ex in] (= ex (parse-p (first (html-snippet in))))
+ {:name "Example User"}
+ "Example User
"
- {:items [{:properties {:nickname "exuser"}}] :rels {}}
- ""))
+ {:nickname "exuser"}
+ "exuser
"))
(deftest parse-p-special-elements
(testing "img, abbr and data elements should be parsed differently"
- (are [ex in] (= ex (parse in))
- {:items [{:properties {:name "Example User"}}] :rels {}}
- ""
+ (are [ex in] (= ex (parse-p (first (html-snippet in))))
+ {:name "Example User"}
+ ""
- {:items [{:properties {:name "Example User"}}] :rels {}}
- ""
+ {:name "Example User"}
+ "@example"
- {:items [{:properties {:name "Example User"}}] :rels {}}
- "")))
+ {:name "Example User"}
+ "")))
(deftest parse-p-empty-br-hr
(testing "br and hr tags should return empty strings"
- (are [ex in] (= ex (parse in))
- {:items [{:properties {:name ""}}] :rels {}}
- "
"
+ (are [ex in] (= ex (parse-p (first (html-snippet in))))
+ {:name ""}
+ "
"
- {:items [{:properties {:name ""}}] :rels {}}
- "
")))
+ {:name ""}
+ "
")))
(deftest parse-u-elements
(testing "Tags should have their values parsed as a u-* value"
- (are [ex in] (= ex (parse in))
- {:items [{:properties {:url "http://example.com"}}] :rels {}}
- ""
+ (are [ex in] (= ex (parse-u (first (html-snippet in))))
+ {:url "http://example.com"}
+ "Awesome example website"
- {:items [{:properties {:photo "http://example.com/someimage.png"}}] :rels {}}
- ""
+ {:photo "http://example.com/someimage.png"}
+ ""
- {:items [{:properties {:photo "http://example.com/someimage.png"}}] :rels {}}
- ""
+ {:photo "http://example.com/someimage.png"}
+ ""
- {:items [{:properties {:photo "http://example.com/someimage.png"}}] :rels {}}
- ""
+ {:photo "http://example.com/someimage.png"}
+ ""
- {:items [{:properties {:photo "http://example.com/someimage.png"}}] :rels {}}
- ""
+ {:photo "http://example.com/someimage.png"}
+ ""
- {:items [{:properties {:photo "http://example.com/someimage.png"}}] :rels {}}
- "")))
+ {:photo "http://example.com/someimage.png"}
+ "")))
--
cgit 1.4.1