Skip to content

Commit

Permalink
Update tests for route maps using string keys instead of keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek authored and weavejester committed Apr 21, 2010
1 parent 85da4dc commit 7574678
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions test/clout/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,42 @@

(deftest keyword-paths
(are [path uri params] (= (route-matches path uri) params)
"/:x" "/foo" {:x "foo"}
"/foo/:x" "/foo/bar" {:x "bar"}
"/a/b/:c" "/a/b/c" {:c "c"}
"/:a/b/:c" "/a/b/c" {:a "a", :c "c"}))
"/:x" "/foo" {"x" "foo"}
"/foo/:x" "/foo/bar" {"x" "bar"}
"/a/b/:c" "/a/b/c" {"c" "c"}
"/:a/b/:c" "/a/b/c" {"a" "a", "c" "c"}))

(deftest keywords-match-extensions
(are [path uri params] (= (route-matches path uri) params)
"/foo.:ext" "/foo.txt" {:ext "txt"}
"/:x.:y" "/foo.txt" {:x "foo", :y "txt"}))
"/foo.:ext" "/foo.txt" {"ext" "txt"}
"/:x.:y" "/foo.txt" {"x" "foo", "y" "txt"}))

(deftest hyphen-keywords
(are [path uri params] (= (route-matches path uri) params)
"/:foo-bar" "/baz" {:foo-bar "baz"}
"/:foo-" "/baz" {:foo- "baz"}))
"/:foo-bar" "/baz" {"foo-bar" "baz"}
"/:foo-" "/baz" {"foo-" "baz"}))

(deftest urlencoded-keywords
(are [path uri params] (= (route-matches path uri) params)
"/:x" "/foo%20bar" {:x "foo bar"}
"/:x" "/foo+bar" {:x "foo bar"}))
"/:x" "/foo%20bar" {"x" "foo bar"}
"/:x" "/foo+bar" {"x" "foo bar"}))

(deftest same-keyword-many-times
(are [path uri params] (= (route-matches path uri) params)
"/:x/:x/:x" "/a/b/c" {:x ["a" "b" "c"]}
"/:x/b/:x" "/a/b/c" {:x ["a" "c"]}))
"/:x/:x/:x" "/a/b/c" {"x" ["a" "b" "c"]}
"/:x/b/:x" "/a/b/c" {"x" ["a" "c"]}))

(deftest wildcard-paths
(are [path uri params] (= (route-matches path uri) params)
"/*" "/foo" {:* "foo"}
"/*" "/foo.txt" {:* "foo.txt"}
"/*" "/foo/bar" {:* "foo/bar"}
"/foo/*" "/foo/bar/baz" {:* "bar/baz"}
"/a/*/d" "/a/b/c/d" {:* "b/c"}))
"/*" "/foo" {"*" "foo"}
"/*" "/foo.txt" {"*" "foo.txt"}
"/*" "/foo/bar" {"*" "foo/bar"}
"/foo/*" "/foo/bar/baz" {"*" "bar/baz"}
"/a/*/d" "/a/b/c/d" {"*" "b/c"}))

(deftest compiled-routes
(is (= (route-matches (route-compile "/foo/:id") "/foo/bar")
{:id "bar"})))
{"id" "bar"})))

(deftest url-paths
(is (route-matches "http://localhost" "http://localhost")))
Expand Down

0 comments on commit 7574678

Please sign in to comment.