-
Notifications
You must be signed in to change notification settings - Fork 1
JESI-2210 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -14,7 +15,8 @@ | |||
(defn js->clj | |||
"Transforms JavaScript to ClojureScript converting keys to kebab-case keywords" | |||
[x] | |||
(transform-keys ->kebab-case-key (clojure.core/js->clj x :keywordize-keys true))) | |||
(when-let [clj (some-> x (clojure.core/js->clj :keywordize-keys true))] | |||
(transform-keys ->kebab-case-key clj))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight optimization to skip if nil
[x] | ||
(js->clj (js/JSON.parse x))) | ||
[s] | ||
(when-not (string/blank? s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank is invalid JSON, so added check
Inspired by https://github.com/r0man/cljs-http/blob/master/src/cljs_http/util.cljs#L60
(assert-eq true "false") | ||
(assert-eq "" "\"\"") | ||
(assert-eq 3.14 "3.14") | ||
(assert-eq 42 "42")))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test all the things!
(assert-eq [] "[]") | ||
(assert-eq nil "null") | ||
(assert-eq true "true") | ||
(assert-eq true "false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ummm....dafaq?
|
||
(testing "parses empty and literal values" | ||
(let [assert-eq (fn [expected s] | ||
(is (= expected) (bp/json->clj s)))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paren mismatch
JESI-2210
https://github.com/jesims/jesi-web/pull/595
https://github.com/jesims/build-scripts/pull/95
https://github.com/jesims/jesi/pull/810