summaryrefslogtreecommitdiff
path: root/test/ruuter
diff options
context:
space:
mode:
authorAsko Nõmm <asko@bien.ee>2021-10-03 12:50:37 -0300
committerAsko Nõmm <asko@bien.ee>2021-10-03 12:50:37 -0300
commite1b8f0969a4bd5f1e1e390364a55ffc6aa141d65 (patch)
tree625dbd89675daa807c375a5df66449b79a72c855 /test/ruuter
parentbf91cdfd50daffaa4814e2271a2eba82674fba76 (diff)
Optional path parameters, ClojureScript support and Babashka example in README
Diffstat (limited to 'test/ruuter')
-rw-r--r--test/ruuter/core_test.clj24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/ruuter/core_test.clj b/test/ruuter/core_test.clj
index c735f1a..4f60054 100644
--- a/test/ruuter/core_test.clj
+++ b/test/ruuter/core_test.clj
@@ -2,31 +2,31 @@
(:require [clojure.test :refer :all]
[ruuter.core :as ruuter]))
-(deftest path->regex-path-test
- (let [testfn #'ruuter/path->regex-path]
- (testing "Converting a path to a regex path with no params"
- (is (= "/hello/world" (testfn "/hello/world"))))
- (testing "Converting a path to a regex path with params"
- (is (= "/hello/.*" (testfn "/hello/:who")))
- (is (= "/.*/.*/.*" (testfn "/:these/:are/:params"))))))
-
(deftest path+uri->path-params-test
(let [testfn #'ruuter/path+uri->path-params]
(testing "No params returns an empty map"
- (is (= {} (testfn "/hello/world" "/hello/world"))))
+ (is (= {}
+ (testfn "/hello/world" "/hello/world"))))
(testing "Having a param returns a map accordingly"
- (is (= {:who "world"} (testfn "/hello/:who" "/hello/world"))))
+ (is (= {:who "world"}
+ (testfn "/hello/:who" "/hello/world"))))
(testing "Multiple params returns a map accordingly"
(is (= {:who "world"
- :why "because"} (testfn "/hello/:who/:why" "/hello/world/because"))))))
+ :why "because"}
+ (testfn "/hello/:who/:why" "/hello/world/because"))))
+ (testing "Multiple params, but one is optional"
+ (is (= {:who "world"}
+ (testfn "/hello/:who/:why?" "/hello/world")))
+ (is (= {:who "world"
+ :why "because"}
+ (testfn "/hello/:who/:why?" "/hello/world/because"))))))
(deftest match-route-test
(let [testfn #'ruuter/match-route]
(testing "Find a route that exists"
(is (= {:path "/hello"
- :regex-path "/hello"
:method :get
:response {:status 200
:body "Hello."}}