diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruuter/core_test.cljc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/test/ruuter/core_test.cljc b/test/ruuter/core_test.cljc index 36c998d..9f47212 100644 --- a/test/ruuter/core_test.cljc +++ b/test/ruuter/core_test.cljc @@ -1,10 +1,12 @@ (ns ruuter.core-test #?(:clj (:require [clojure.test :refer :all] - [ruuter.core :as ruuter])) - #?(:cljs (:require [cljs.test :refer-macros [deftest testing is]] + [ruuter.core :as ruuter]) + :cljs (:require [cljs.test :refer-macros [deftest testing is]] + [ruuter.core :as ruuter]) + :jank (:require [clojure.test :refer [deftest testing is run-tests]] [ruuter.core :as ruuter]))) -;; ── Required Param Tests ──────────────────────────────────────────────── +;; -- Required Param Tests -- (deftest no-params-test (testing "No params returns an empty params map" @@ -29,7 +31,7 @@ {:uri "/hello/world/because" :request-method :get}) (is (= {:who "world" :why "because"} @params))))) -;; ── Optional Param Tests ─────────────────────────────────────────────── +;; -- Optional Param Tests -- (deftest optional-param-test (testing "Required and optional param — both present" @@ -60,7 +62,7 @@ {:uri "/hello/world" :request-method :get}) (is (= {:who "world"} @params))))) -;; ── Wildcard Param Tests ─────────────────────────────────────────────── +;; -- Wildcard Param Tests -- (deftest wildcard-param-test (testing "Wildcard param" @@ -84,7 +86,7 @@ {:uri "/user/123/file/a/b/c/foo.txt" :request-method :get}) (is (= {:id "123" :path "a/b/c/foo.txt"} @params))))) -;; ── Route Matching Tests ─────────────────────────────────────────────── +;; -- Route Matching Tests -- (deftest match-route-test (testing "Finds a matching route" @@ -109,7 +111,7 @@ :response {:status 200 :body "root"}}] {:uri "/" :request-method :get}))))) -;; ── Response Tests ───────────────────────────────────────────────────── +;; -- Response Tests -- (deftest response-test (testing "Returns a map when the response is a direct map" @@ -152,7 +154,7 @@ :params {:who "overwritten"}}) (is (= {:who "overwritten"} @params))))) -;; ── Best-Match / Specificity Tests ───────────────────────────────────── +;; -- Best-Match / Specificity Tests -- (deftest literal-beats-param-test (testing "Literal beats param regardless of route order" @@ -223,7 +225,7 @@ :response {:status 200 :body "wildcard"}}] {:uri "/hello/a/b/c" :request-method :get}))))) -;; ── Not-Found Fallback Tests ─────────────────────────────────────────── +;; -- Not-Found Fallback Tests -- (deftest not-found-test (testing "Custom :not-found route is used when no match" @@ -248,7 +250,7 @@ :response {:status 200 :body "hi"}}] {:uri "/nope" :request-method :get}))))) -;; ── Compile-Routes Tests ─────────────────────────────────────────────── +;; -- Compile-Routes Tests -- (deftest compile-routes-test (testing "Pre-compiled routes work the same as raw routes" @@ -264,7 +266,7 @@ (is (= {:status 404 :body "custom 404"} (ruuter/route compiled {:uri "/nope" :request-method :get})))))) -;; ── Edge Case Tests ──────────────────────────────────────────────────── +;; -- Edge Case Tests -- (deftest trie-node-reuse-test (testing "Two routes sharing same param slot — trie reuses param node" |
