Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
fixup: fix test, add test for :compojure/context
Browse files Browse the repository at this point in the history
  • Loading branch information
calvis committed Apr 26, 2022
1 parent cd218f7 commit e8ff6e0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/compojure/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
(assoc :params {:y "bar"}))]
((GET "/:x" [x :as r]
(is (= x "foo"))
(is (= (dissoc r :params :route-params :compojure/route)
(is (= (dissoc r :params :route-params :compojure/route :compojure/full-route)
(dissoc req :params)))
nil)
req)))
Expand Down Expand Up @@ -323,11 +323,17 @@
request (route (mock/request :post "/foo/1" {}))]
(testing "ANY request has matched route information"
(is (= (request :compojure/route)
[:any "/foo/:id"]))))
[:any "/foo/:id"]))
(is (= (request :compojure/full-route)
"/foo/:id"))))

(let [route (context "/foo/:foo-id" [_] (GET "/bar/:bar-id" req req))
request (route (mock/request :get "/foo/1/bar/2"))]
(testing "request has matched route information with path prefix"
(is (= (request :compojure/route)
[:get "/bar/:bar-id"]))
(is (= (request :compojure/context)
"/foo/:foo-id"))
(is (= (request :compojure/full-route)
"/foo/:foo-id/bar/:bar-id"))))

Expand All @@ -336,6 +342,8 @@
(GET "/baz/:baz-id" req req)))
request (route (mock/request :get "/foo/1/bar/2/baz/3"))]
(testing "request has matched route information with multiple path prefix"
(is (= (request :compojure/context)
"/foo/:foo-id/bar/:bar-id"))
(is (= (request :compojure/full-route)
"/foo/:foo-id/bar/:bar-id/baz/:baz-id")))))

Expand Down

0 comments on commit e8ff6e0

Please sign in to comment.