(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}]) "")))