Skip to content

Commit

Permalink
Merge pull request #84 from yetanalytics/cljs_raw_string
Browse files Browse the repository at this point in the history
resolved raw string cljs statement-data bug
  • Loading branch information
cliffcaseyyet authored Jan 17, 2024
2 parents 4aae5ff + b2cf6bd commit 84e2199
Show file tree
Hide file tree
Showing 2 changed files with 8 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
8 changes: 7 additions & 1 deletion test/xapi_schema/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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 84e2199

Please sign in to comment.