parent
4aa80950e5
commit
554e69d914
@ -0,0 +1,17 @@
|
||||
(ns wanijo.framework.routing-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[wanijo.framework.routing :refer [parse-path]]))
|
||||
|
||||
(deftest test-parse-path
|
||||
(testing "no params in path"
|
||||
(is (= (parse-path "a" {}) "a"))
|
||||
(is (= (parse-path "/a/b" {}) "/a/b")))
|
||||
(testing "params are replaced"
|
||||
(is (= (parse-path "/a/:b" {:b 1}) "/a/1"))
|
||||
(is (= (parse-path "/a/:b" {:b "1"}) "/a/1"))
|
||||
(is (= (parse-path ":b" {:b 1}) "1"))
|
||||
(is (= (parse-path "/a/:b/c" {:b 1}) "/a/1/c")))
|
||||
(testing "additional params are ignored"
|
||||
(is (= (parse-path ":a" {:a 1 :b 2}) "1")))
|
||||
(testing "all params are required"
|
||||
(is (thrown? RuntimeException (parse-path ":a")))))
|
Loading…
Reference in new issue