Skip to content

Commit 84e2199

Browse files
Merge pull request #84 from yetanalytics/cljs_raw_string
resolved raw string cljs statement-data bug
2 parents 4aae5ff + b2cf6bd commit 84e2199

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/xapi_schema/core.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
:else sd))
4040
:cljs (validate-statement-data*
4141
(cond
42-
(string? sd) (.parse js/JSON sd)
42+
(string? sd) (js->clj (.parse js/JSON sd))
4343
:else sd))))
4444

4545
#?(:cljs

test/xapi_schema/core_test.cljc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@
7373
(testing "with string data"
7474
(let [statement (json/write-str long-statement)]
7575
(testing "it parses and returns the validated data"
76-
(is (= long-statement (validate-statement-data statement)))))))
76+
(is (= long-statement (validate-statement-data statement))))))
77+
:cljs
78+
(testing "with string data"
79+
(let [json (clj->js long-statement)
80+
json-str (.stringify js/JSON json)]
81+
(testing "it parses and returns the validated data"
82+
(is (= long-statement (validate-statement-data json-str)))))))
7783

7884
#?(:cljs
7985
(testing "with nested data"

0 commit comments

Comments
 (0)