forked from KevinKelley/compojure-rest
/
test_all.clj
30 lines (23 loc) · 875 Bytes
/
test_all.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(ns test-all
(:use compojure-rest)
(:use clojure.test)
(:import java.util.Date))
(deftest test-evaluate-generate
(testing "with simple vaule"
(is (= :v (evaluate-generate :v {}))))
(testing "with constant function"
(is (= :c (evaluate-generate (fn [request] :c) {}))))
(testing "with function"
(is (= :a (evaluate-generate (fn [request] (request :x)) { :x :a})))))
(deftest test-http-date
(testing "with zero-date"
(is (= "Thu, 01 Jan 1970 00:00:00 +0000" (http-date (new Date (long 0)) "UTC")))))
(deftest test-wrap-header
(testing "with simple value"
(is (= { :body "x" :headers { "header" "foo" }}
((wrap-header (fn [req] { :body "x"})
"header" "foo") {}))))
(testing "with function"
(is (= { :body "x" :headers { "header" "foo" }}
((wrap-header (fn [req] { :body "x"})
"header" (fn [req] "foo")) {})))))