mirror of
https://github.com/metosin/reitit.git
synced 2025-12-26 03:38:24 +00:00
Add tests for intermediate frontend paths
Added failing tests for resolving intermediate paths in frontend. See Github issue #175.
This commit is contained in:
parent
6bf4335f84
commit
a68ac257e7
1 changed files with 35 additions and 1 deletions
|
|
@ -113,4 +113,38 @@
|
|||
(:messages
|
||||
(capture-console
|
||||
(fn []
|
||||
(rf/match-by-name! router ::foo {}))))))))))
|
||||
(rf/match-by-name! router ::foo {})))))))))
|
||||
|
||||
(testing "intermediate paths"
|
||||
(testing "without conflicting routes"
|
||||
(let [routes ["/" {:name ::root}
|
||||
["foo" {:name ::foo}]
|
||||
["bar" {:name ::bar}
|
||||
["/baz" {:name ::baz}]]]
|
||||
router (rf/router routes)
|
||||
match #(rf/match-by-path router %)
|
||||
expected (fn [path name] (r/map->Match {:template path
|
||||
:path path
|
||||
:data {:name name}
|
||||
:path-params {}
|
||||
:query-params {}
|
||||
:parameters {:query {}
|
||||
:path {}}}))]
|
||||
(are [path name]
|
||||
(is (= (expected path name)
|
||||
(match path)))
|
||||
"/" ::root
|
||||
"/foo" ::foo
|
||||
"/bar" ::bar
|
||||
"/bar/baz" ::baz)))
|
||||
|
||||
(testing "with conflicting routes"
|
||||
(let [routes ["/" {:name ::root}
|
||||
["" {:name ::frontpage}]
|
||||
["foo" {:name ::foo}]
|
||||
["bar" {:name ::bar}
|
||||
["/baz" {:name ::baz}]]]]
|
||||
(is (thrown-with-msg?
|
||||
ExceptionInfo
|
||||
#"Router contains conflicting route paths"
|
||||
(rf/router routes)))))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue