Skip to content

Commit

Permalink
resolved raw string cljs statement-data bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffcaseyyet committed Jan 16, 2024
1 parent 4aae5ff commit 7a194ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit 7a194ce

Please sign in to comment.