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 --- .../test/compojure/html/page_helpers_test.clj | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 compojure-3.2/test/compojure/html/page_helpers_test.clj (limited to 'compojure-3.2/test/compojure/html/page_helpers_test.clj') diff --git a/compojure-3.2/test/compojure/html/page_helpers_test.clj b/compojure-3.2/test/compojure/html/page_helpers_test.clj new file mode 100755 index 0000000..fe29481 --- /dev/null +++ b/compojure-3.2/test/compojure/html/page_helpers_test.clj @@ -0,0 +1,71 @@ +(ns compojure.html.page-helpers-test + (:use compojure.html.page-helpers + clojure.contrib.test-is)) + +(deftest test-doctype + (testing "html4" + (is (= (doctype :html4) + (str "\n")))) + (testing "xhtml-strict" + (is (= (doctype :xhtml-strict) + (str "\n")))) + (testing "html5" + (is (= (doctype :html5) + (str "")))) + (testing "xhtml-transitional" + (is (= (doctype :xhtml-transitional) + (str "\n"))))) + +(deftest test-xhtml-tag + (is (= (xhtml-tag "test") + [:html {:xmlns "http://www.w3.org/1999/xhtml", "xml:lang" "test", :lang "test"} nil]))) + +(deftest test-include-js + (testing "one" + (is (= (include-js "foo.js") + '([:script {:type "text/javascript", :src "foo.js"}])))) + (testing "many" + (is (= (include-js "foo.js" "bar.js" "baz.js") + '([:script {:type "text/javascript", :src "foo.js"}] + [:script {:type "text/javascript", :src "bar.js"}] + [:script {:type "text/javascript", :src "baz.js"}]))))) + +(deftest test-include-css + (testing "one" + (is (= (include-css "foo.css") + '([:link {:type "text/css" :href "foo.css" :rel "stylesheet"}])))) + (testing "many" + (is (= (include-css "foo.css" "bar.css" "baz.css") + '([:link {:type "text/css", :href "foo.css", :rel "stylesheet"}] + [:link {:type "text/css", :href "bar.css", :rel "stylesheet"}] + [:link {:type "text/css", :href "baz.css", :rel "stylesheet"}]))))) + +(deftest test-javascript-tag + (is (= (javascript-tag "alert('hi');") + [:script {:type "text/javascript"} + (str "//")]))) + +(deftest test-link-to + (is (= (link-to "http://compojure.org") + [:a {:href "http://compojure.org"} nil]))) + +(deftest test-url-encode + (is (= (url-encode "foo&bar*/baz.net") + (str "foo%26bar*%2Fbaz.net")))) + +(deftest test-url-params + (is (= (url-params "http://example.com" {:lang "en", :offset 10}) + "http://example.com?lang=en&offset=10"))) + +(deftest test-unordered-list + (is (= (unordered-list ["a" "b"]) + [:ul {} + '([:li "a"] [:li "b"])]))) + +(deftest test-ordered-list + (is (= (ordered-list ["b" "a"]) + [:ol {} + '([:li "b"] [:li "a"])]))) \ No newline at end of file -- cgit v1.2.3-70-g09d2