From f3058b90fe38d0304effb7fb8a24024589864afd Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Sat, 17 Mar 2018 14:35:28 +0200 Subject: [PATCH] Fix tests for cljs --- test/cljc/reitit/swagger_test.clj | 58 +++---------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/test/cljc/reitit/swagger_test.clj b/test/cljc/reitit/swagger_test.clj index 8edcd777..e7ee183e 100644 --- a/test/cljc/reitit/swagger_test.clj +++ b/test/cljc/reitit/swagger_test.clj @@ -4,7 +4,8 @@ [reitit.swagger :as swagger] [reitit.ring.coercion :as rrc] [reitit.coercion.spec :as spec] - [reitit.coercion.schema :as schema])) + [reitit.coercion.schema :as schema] + [schema.core :refer [Int]])) (def app (ring/ring-handler @@ -18,14 +19,6 @@ :handler swagger/swagger-spec-handler}}] ["/spec" {:coercion spec/coercion} - - ["/minus" - {:get {:summary "minus" - :parameters {:query {:x int?, :y int?}} - :responses {200 {:body {:total int?}}} - :handler (fn [{{{:keys [x y]} :query} :parameters}] - {:status 200, :body {:total (- x y)}})}}] - ["/plus" {:get {:summary "plus" :parameters {:query {:x int?, :y int?}} @@ -34,18 +27,10 @@ {:status 200, :body {:total (+ x y)}})}}]] ["/schema" {:coercion schema/coercion} - - ["/minus" - {:get {:summary "minus" - :parameters {:query {:x Long, :y Long}} - :responses {200 {:body {:total Long}}} - :handler (fn [{{{:keys [x y]} :query} :parameters}] - {:status 200, :body {:total (- x y)}})}}] - ["/plus" {:get {:summary "plus" - :parameters {:query {:x Long, :y Long}} - :responses {200 {:body {:total Long}}} + :parameters {:query {:x Int, :y Int}} + :responses {200 {:body {:total Int}}} :handler (fn [{{{:keys [x y]} :query} :parameters}] {:status 200, :body {:total (+ x y)}})}}]]] @@ -61,22 +46,12 @@ (app {:request-method :get :uri "/api/spec/plus" - :query-params {:x "2", :y "1"}}))) - (is (= {:body {:total 1}, :status 200} - (app - {:request-method :get - :uri "/api/spec/minus" :query-params {:x "2", :y "1"}})))) (testing "schema" (is (= {:body {:total 3}, :status 200} (app {:request-method :get :uri "/api/schema/plus" - :query-params {:x "2", :y "1"}}))) - (is (= {:body {:total 1}, :status 200} - (app - {:request-method :get - :uri "/api/schema/minus" :query-params {:x "2", :y "1"}}))))) (testing "swagger-spec" (let [spec (:body (app @@ -84,30 +59,7 @@ :uri "/api/swagger.json"}))] (is (= {:x-id ::math :info {:title "my-api"} - :paths { - ;; schema doesn't yet generate parameter data - "/api/schema/minus" {:get {:summary "minus"}} - "/api/schema/plus" {:get {:summary "plus"}} - - ;; spec does! - "/api/spec/minus" {:get {:parameters [{:description "" - :format "int64" - :in "query" - :name "x" - :required true - :type "integer"} - {:description "" - :format "int64" - :in "query" - :name "y" - :required true - :type "integer"}] - :responses {200 {:description "" - :schema {:properties {"total" {:format "int64" - :type "integer"}} - :required ["total"] - :type "object"}}} - :summary "minus"}} + :paths {"/api/schema/plus" {:get {:summary "plus"}} ;; TODO: implement! "/api/spec/plus" {:get {:parameters [{:description "" :format "int64" :in "query"