Skip to content

Commit

Permalink
Delete commented specs
Browse files Browse the repository at this point in the history
Until day8#33 is ready, delete commented code.
  • Loading branch information
superstructor committed May 15, 2019
1 parent 4cd1cd9 commit 927db4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 48 deletions.
33 changes: 2 additions & 31 deletions src/day8/re_frame/http_fx.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
(:require
[goog.net.ErrorCode :as errors]
[re-frame.core :refer [reg-fx dispatch console]]
[ajax.core :as ajax]
#_[cljs.spec :as s]))
[ajax.core :as ajax]))

;; I provide the :http-xhrio effect handler leveraging cljs-ajax lib
;; see API docs https://github.com/JulianBirch/cljs-ajax
Expand Down Expand Up @@ -52,37 +51,9 @@
api))
(dissoc :on-success :on-failure))))

;; Specs commented out until ClojureScript has a stable release of spec.
;
;(s/def ::method keyword?)
;(s/def ::uri string?)
;(s/def ::response-format (s/keys :req-un [::description ::read ::content-type]))
;(s/def ::format (s/keys :req-un [::write ::content-type]))
;(s/def ::timeout nat-int?)
;(s/def ::params any?)
;(s/def ::headers map?)
;(s/def ::with-credentials boolean?)
;
;(s/def ::on-success vector?)
;(s/def ::on-failure vector?)
;
;(s/def ::request-map (s/and (s/keys :req-un [::method ::uri ::response-format ::on-success ::on-failure]
; :opt-un [::format ::timeout ::params ::headers ::with-credentials])
; (fn [m] (if (contains? m :params)
; (contains? m :format)
; true))))
;
;(s/def ::sequential-or-map (s/or :request-map ::request-map :seq-request-maps (s/coll-of ::request-map
; :kind sequential?
; :into [])))

(defn http-effect
[request]
#_(when-not (s/valid? ::sequential-or-map request)
(throw (ex-info "http-xhrio fx: spec error" (s/explain-data ::sequential-or-map request))))
(let [#_ #_ [conform-val v] (s/conform ::sequential-or-map request)
#_ #_ seq-request-maps (if (= :seq-request-maps conform-val) v [v])
seq-request-maps (if (sequential? request) request [request])]
(let [seq-request-maps (if (sequential? request) request [request])]
(doseq [request seq-request-maps]
(-> request request->xhrio-options ajax/ajax-request))))

Expand Down
18 changes: 1 addition & 17 deletions test/day8/re_frame/http_fx_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,4 @@
:timeout 5000
:response-format (ajax/json-response-format {:keywords? true})
:on-success [::good-http-result done "test-token1"]
:on-failure [::bad-http-result done "test-token1"]}]])))

; Commented out until we re-enable spec
;(deftest invalid-fx-test
; (is (= ::s/invalid
; (s/conform ::http-fx/request-map {})))
; (is (= ::s/invalid
; (s/conform ::http-fx/request-map {:method :get
; :uri "https://api.github.com"
; :response-format :json
; :on-success [:x]
; :on-failure [:y]})))
; (is (= ::s/invalid
; (s/conform ::http-fx/request-map {:method :get
; :uri "https://api.github.com"
; :response-format (ajax/json-response-format)
; :on-success [:x]}))))
:on-failure [::bad-http-result done "test-token1"]}]])))

0 comments on commit 927db4a

Please sign in to comment.