Skip to content
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

resolved raw string cljs statement-data bug #84

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/xapi_schema/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
:else sd))
:cljs (validate-statement-data*
(cond
(string? sd) (.parse js/JSON sd)
(string? sd) (js->clj (.parse js/JSON sd))
:else sd))))

#?(:cljs
Expand Down
9 changes: 8 additions & 1 deletion test/xapi_schema/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
validate-statements
validate-statement-data
#?(:cljs validate-statement-data-js)]]
[clojure.pprint :refer [pprint]]
#?(:clj [clojure.data.json :as json]
:cljs [cljs.core :refer [ExceptionInfo]]))
#?(:clj (:import [clojure.lang ExceptionInfo])))
Expand Down Expand Up @@ -73,7 +74,13 @@
(testing "with string data"
(let [statement (json/write-str long-statement)]
(testing "it parses and returns the validated data"
(is (= long-statement (validate-statement-data statement)))))))
(is (= long-statement (validate-statement-data statement))))))
:cljs
(testing "with string data"
(let [json (clj->js long-statement)
json-str (.stringify js/JSON json)]
(testing "it parses and returns the validated data"
(is (= long-statement (validate-statement-data json-str)))))))

#?(:cljs
(testing "with nested data"
Expand Down