mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 08:21: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)))))
|
||||
|
||||
(defn- token->href [history token]
|
||||
(str (if (.-useFragment_ history)
|
||||
(str "#"))
|
||||
(.getPathPrefix history)
|
||||
token))
|
||||
(if token
|
||||
(str (if (.-useFragment_ history)
|
||||
(str "#"))
|
||||
(.getPathPrefix history)
|
||||
token)))
|
||||
|
||||
(def ^:private current-domain (.getDomain (.parse Uri js/location)))
|
||||
|
||||
|
|
@ -110,7 +111,10 @@
|
|||
token (match->token history match k params query)]
|
||||
(token->href history token))))
|
||||
|
||||
(defn replace-token [{:keys [router history]} k params]
|
||||
(let [match (rf/match-by-name router k params)
|
||||
token (match->token history match k params query)]
|
||||
(.replaceToken history token)))
|
||||
(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)
|
||||
token (match->token history match k params query)]
|
||||
(.replaceToken history token))))
|
||||
|
|
|
|||
|
|
@ -12,5 +12,4 @@
|
|||
[metosin/reitit-schema]
|
||||
[metosin/reitit-swagger]
|
||||
[metosin/reitit-swagger-ui]
|
||||
[metosin/reitit-frontend]
|
||||
[metosin/reitit-re-frame]])
|
||||
[metosin/reitit-frontend]])
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@
|
|||
(is (= "#/bar/5"
|
||||
(rfh/href history ::bar {:id 5})))
|
||||
(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
|
||||
(let [router (r/router ["/"
|
||||
|
|
@ -37,4 +39,6 @@
|
|||
(is (= "/bar/5"
|
||||
(rfh/href history ::bar {:id 5})))
|
||||
(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