From ed1c2b0c4fb6c0b29adf25f7996c359831a2e341 Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Wed, 21 Nov 2018 16:02:04 +0200 Subject: [PATCH] Add coercion tests for vector data-specs, 0.2.9 --- CHANGELOG.md | 6 ++++++ test/cljc/reitit/coercion_test.cljc | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55fe8837..011aefdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.2.9 (2018-11-21) + +## `reitit-spec` + +* support for vector data-specs for request & response parameters by [Heikki Hämäläinen](https://github.com/hjhamala). + ## 0.2.8 (2018-11-18) ## `reitit-core` diff --git a/test/cljc/reitit/coercion_test.cljc b/test/cljc/reitit/coercion_test.cljc index b4c5e5a5..202667fd 100644 --- a/test/cljc/reitit/coercion_test.cljc +++ b/test/cljc/reitit/coercion_test.cljc @@ -14,11 +14,11 @@ [["/schema" {:coercion reitit.coercion.schema/coercion} ["/:number/:keyword" {:parameters {:path {:number s/Int :keyword s/Keyword} - :query (s/maybe {:int s/Int})}}]] + :query (s/maybe {:int s/Int, :ints [s/Int]})}}]] ["/spec" {:coercion reitit.coercion.spec/coercion} ["/:number/:keyword" {:parameters {:path {:number int? :keyword keyword?} - :query (ds/maybe {:int int?})}}]] + :query (ds/maybe {:int int?, :ints [int?]})}}]] ["/none" ["/:number/:keyword" {:parameters {:path {:number int? :keyword keyword?}}}]]] @@ -30,8 +30,8 @@ (is (= {:path {:keyword :abba, :number 1}, :query nil} (coercion/coerce! m)))) (let [m (r/match-by-path r "/schema/1/abba")] - (is (= {:path {:keyword :abba, :number 1}, :query {:int 10}} - (coercion/coerce! (assoc m :query-params {:int "10"})))))) + (is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3]}} + (coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"]})))))) (testing "throws with invalid input" (let [m (r/match-by-path r "/schema/kikka/abba")] (is (thrown? ExceptionInfo (coercion/coerce! m)))))) @@ -42,8 +42,8 @@ (is (= {:path {:keyword :abba, :number 1}, :query nil} (coercion/coerce! m)))) (let [m (r/match-by-path r "/schema/1/abba")] - (is (= {:path {:keyword :abba, :number 1}, :query {:int 10}} - (coercion/coerce! (assoc m :query-params {:int "10"})))))) + (is (= {:path {:keyword :abba, :number 1}, :query {:int 10, :ints [1,2,3]}} + (coercion/coerce! (assoc m :query-params {"int" "10", "ints" ["1" "2" "3"]})))))) (testing "throws with invalid input" (let [m (r/match-by-path r "/spec/kikka/abba")] (is (thrown? ExceptionInfo (coercion/coerce! m))))))