diff --git a/test/cljs/reitit/frontend/core_test.cljs b/test/cljs/reitit/frontend/core_test.cljs index 22ac1db2..6e77af71 100644 --- a/test/cljs/reitit/frontend/core_test.cljs +++ b/test/cljs/reitit/frontend/core_test.cljs @@ -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)))))))