summaryrefslogtreecommitdiff
path: root/test/ruuter/core_test.cljc
diff options
context:
space:
mode:
authorAsko Nõmm <ano@ano.ee>2022-10-05 22:29:03 +0300
committerAsko Nõmm <ano@ano.ee>2022-10-05 22:29:03 +0300
commit9e8abbf26d4422ba133bba7186363bee5b1f38d7 (patch)
tree152702f0d75313eb26a6b2d79b7f208ac039e399 /test/ruuter/core_test.cljc
parent78659212f95cac827efc816dfbdab8181c25fc3d (diff)
1.3.0
Diffstat (limited to 'test/ruuter/core_test.cljc')
-rw-r--r--test/ruuter/core_test.cljc14
1 files changed, 10 insertions, 4 deletions
diff --git a/test/ruuter/core_test.cljc b/test/ruuter/core_test.cljc
index 9f1df23..75a71a0 100644
--- a/test/ruuter/core_test.cljc
+++ b/test/ruuter/core_test.cljc
@@ -4,7 +4,6 @@
#?(:cljs (:require [cljs.test :refer-macros [deftest testing is]]
[ruuter.core :as ruuter])))
-
(deftest path+uri->path-params-test
(let [testfn #'ruuter/path+uri->path-params]
(testing "No params returns an empty map"
@@ -22,8 +21,16 @@
(testfn "/hello/:who/:why?" "/hello/world")))
(is (= {:who "world"
:why "because"}
- (testfn "/hello/:who/:why?" "/hello/world/because"))))))
-
+ (testfn "/hello/:who/:why?" "/hello/world/because"))))
+ (testing "Multiple params, but all are optional"
+ (is (= {:who "world"
+ :why "because"}
+ (testfn "hello/:who?/:why?" "/hello/world/because")))
+ (is (= {:who "world"}
+ (testfn "hello/:who?/:why?" "/hello/world"))))
+ (testing "Wildcard param"
+ (is (= {:everything* "this/means/literally/everything"}
+ (testfn "hello/:everything*" "/hello/this/means/literally/everything"))))))
(deftest match-route-test
(let [testfn #'ruuter/match-route]
@@ -40,7 +47,6 @@
(is (= nil
(testfn [] "/hello" :get))))))
-
(deftest route+req->response-test
(let [testfn #'ruuter/route+req->response]
(testing "Returning a map when the response is a direct map"