From d3fcf8d56122514c3dcbac004fcf105a4e899352 Mon Sep 17 00:00:00 2001 From: sostler Date: Wed, 10 Feb 2010 01:08:44 -0500 Subject: Added custom compojure tree --- compojure-3.2/test/compojure/html/gen_test.clj | 93 ++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 compojure-3.2/test/compojure/html/gen_test.clj (limited to 'compojure-3.2/test/compojure/html/gen_test.clj') diff --git a/compojure-3.2/test/compojure/html/gen_test.clj b/compojure-3.2/test/compojure/html/gen_test.clj new file mode 100755 index 0000000..5d64b7c --- /dev/null +++ b/compojure-3.2/test/compojure/html/gen_test.clj @@ -0,0 +1,93 @@ +(ns compojure.html.gen-test + (:use compojure.html.gen + clojure.contrib.test-is)) + +(deftest tag-text + (is (= (html [:text "Lorem Ipsum"]) "Lorem Ipsum"))) + +(deftest empty-tags + (is (= (html [:text]) ""))) + +(deftest empty-block-tags + (is (= (html [:div]) "
")) + (is (= (html [:h1]) "

")) + (is (= (html [:script]) ""))) + +(deftest empty-links-tag + (is (= (html [:a]) ""))) + +(deftest tags-can-be-strs + (is (= (html ["div"] "
")))) + +(deftest tags-can-be-symbols + (is (= (html ['div] "
")))) + +(deftest tag-concatenation + (is (= (html [:body "foo" "bar"]) "foobar")) + (is (= (html [:body [:p] [:br]])) "


")) + +(deftest tag-seq-expand + (is (= (html [:body (list "foo" "bar")]) + "foobar"))) + +(deftest html-seq-expand + (is (= (html (list [:p "a"] [:p "b"])) + "

a

b

"))) + +(deftest nested-tags + (is (= (html [:div [:p]] "

"))) + (is (= (html [:div [:b]] "
"))) + (is (= (html [:p [:span [:a "foo"]]]) + "

foo

"))) + +(deftest attribute-maps + (is (= (html [:xml {:a "1", :b "2"}]) + ""))) + +(deftest blank-attribute-map + (is (= (html [:xml {}]) ""))) + +(deftest escaped-chars + (is (= (escape-html "\"") """)) + (is (= (escape-html "<") "<")) + (is (= (escape-html ">") ">")) + (is (= (escape-html "&") "&"))) + +(deftest escaped-attrs + (is (= (html [:div {:id "\""}]) + "
"))) + +(deftest attrs-can-be-strs + (is (= (html [:img {"id" "foo"}]) ""))) + +(deftest attrs-can-be-symbols + (is (= (html [:img {'id "foo"}]) ""))) + +(deftest attr-keys-different-types + (is (= (html [:xml {:a "1", 'b "2", "c" "3"}]) + ""))) + +(deftest tag-class-sugar + (is (= (html [:div.foo]) "
"))) + +(deftest tag-many-class-sugar + (is (= (html [:div.a.b]) "
")) + (is (= (html [:div.a.b.c]) "
"))) + +(deftest tag-id-sugar + (is (= (html [:div#foo]) "
"))) + +(deftest tag-id-and-classes + (is (= (html [:div#foo.bar.baz]) + "
"))) + +(deftest html-not-indented + (is (= (html [:p "Lorem\nIpsum"]) "

Lorem\nIpsum

"))) + +(deftest attrs-bool-true + (is (= (html [:input {:type "checkbox" :checked true}]) + ""))) + +(deftest attrs-bool-false + (is (= (html [:input {:type "checkbox" :checked false}]) + ""))) -- cgit v1.2.3-70-g09d2