mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 16:31:11 +00:00
Fix tests
This commit is contained in:
parent
6553795cb5
commit
50faacab25
3 changed files with 19 additions and 12 deletions
|
|
@ -22,10 +22,11 @@
|
||||||
(count (.getPathPrefix history)))))
|
(count (.getPathPrefix history)))))
|
||||||
|
|
||||||
(defn- token->href [history token]
|
(defn- token->href [history token]
|
||||||
|
(if token
|
||||||
(str (if (.-useFragment_ history)
|
(str (if (.-useFragment_ history)
|
||||||
(str "#"))
|
(str "#"))
|
||||||
(.getPathPrefix history)
|
(.getPathPrefix history)
|
||||||
token))
|
token)))
|
||||||
|
|
||||||
(def ^:private current-domain (.getDomain (.parse Uri js/location)))
|
(def ^:private current-domain (.getDomain (.parse Uri js/location)))
|
||||||
|
|
||||||
|
|
@ -110,7 +111,10 @@
|
||||||
token (match->token history match k params query)]
|
token (match->token history match k params query)]
|
||||||
(token->href history token))))
|
(token->href history token))))
|
||||||
|
|
||||||
(defn replace-token [{:keys [router history]} k params]
|
(defn replace-token
|
||||||
|
([state k params]
|
||||||
|
(replace-token state k params nil))
|
||||||
|
([{:keys [router history]} k params query]
|
||||||
(let [match (rf/match-by-name router k params)
|
(let [match (rf/match-by-name router k params)
|
||||||
token (match->token history match k params query)]
|
token (match->token history match k params query)]
|
||||||
(.replaceToken history token)))
|
(.replaceToken history token))))
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,4 @@
|
||||||
[metosin/reitit-schema]
|
[metosin/reitit-schema]
|
||||||
[metosin/reitit-swagger]
|
[metosin/reitit-swagger]
|
||||||
[metosin/reitit-swagger-ui]
|
[metosin/reitit-swagger-ui]
|
||||||
[metosin/reitit-frontend]
|
[metosin/reitit-frontend]])
|
||||||
[metosin/reitit-re-frame]])
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@
|
||||||
(is (= "#/bar/5"
|
(is (= "#/bar/5"
|
||||||
(rfh/href history ::bar {:id 5})))
|
(rfh/href history ::bar {:id 5})))
|
||||||
(is (= "#/bar/5?q=x"
|
(is (= "#/bar/5?q=x"
|
||||||
(rfh/href history ::bar {:id 5} {:q "x"}))))))
|
(rfh/href history ::bar {:id 5} {:q "x"})))
|
||||||
|
(is (= nil
|
||||||
|
(rfh/href history ::asd))))))
|
||||||
|
|
||||||
(deftest html5-history-test
|
(deftest html5-history-test
|
||||||
(let [router (r/router ["/"
|
(let [router (r/router ["/"
|
||||||
|
|
@ -37,4 +39,6 @@
|
||||||
(is (= "/bar/5"
|
(is (= "/bar/5"
|
||||||
(rfh/href history ::bar {:id 5})))
|
(rfh/href history ::bar {:id 5})))
|
||||||
(is (= "/bar/5?q=x"
|
(is (= "/bar/5?q=x"
|
||||||
(rfh/href history ::bar {:id 5} {:q "x"}))))))
|
(rfh/href history ::bar {:id 5} {:q "x"})))
|
||||||
|
(is (= nil
|
||||||
|
(rfh/href history ::asd))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue