Skip to content

Commit 7a194ce

Browse files
committed
resolved raw string cljs statement-data bug
1 parent 4aae5ff commit 7a194ce

2 files changed

Lines changed: 9 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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
validate-statements
99
validate-statement-data
1010
#?(:cljs validate-statement-data-js)]]
11+
[clojure.pprint :refer [pprint]]
1112
#?(:clj [clojure.data.json :as json]
1213
:cljs [cljs.core :refer [ExceptionInfo]]))
1314
#?(:clj (:import [clojure.lang ExceptionInfo])))
@@ -73,7 +74,13 @@
7374
(testing "with string data"
7475
(let [statement (json/write-str long-statement)]
7576
(testing "it parses and returns the validated data"
76-
(is (= long-statement (validate-statement-data statement)))))))
77+
(is (= long-statement (validate-statement-data statement))))))
78+
:cljs
79+
(testing "with string data"
80+
(let [json (clj->js long-statement)
81+
json-str (.stringify js/JSON json)]
82+
(testing "it parses and returns the validated data"
83+
(is (= long-statement (validate-statement-data json-str)))))))
7784

7885
#?(:cljs
7986
(testing "with nested data"

0 commit comments

Comments
 (0)