Permalink
Browse files

exports the cljs->js and js->cljs utils; write tests for those; build…

…s fine, tests pass
  • Loading branch information...
1 parent 342ac05 commit 996979558e751976964052ca84a3742f7fb6b77a @michaelsbradleyjr michaelsbradleyjr committed May 6, 2013
Showing with 26 additions and 1 deletion.
  1. +22 −0 spec/mori-spec.js
  2. +4 −1 src/mori.cljs
View
@@ -164,3 +164,25 @@ describe("Juxtaposition", function () {
});
});
+
+describe("Conversion utilities", function () {
+
+ it("demonstrates conversion from clojurescript values to javascript objects, and vice versa", function () {
+
+ var js_obj = { a: 1, b: "two" },
+ js_arr = [1, 2, 3],
+ clj_map = mori.hash_map("a", 1, "b", "two"),
+ clj_vec = mori.vector(1, 2, 3);
+
+
+ expect(mori.equals(mori.js_to_clj(js_obj), clj_map)).toBe(true);
+
+ expect(mori.equals(mori.js_to_clj(js_arr), clj_vec)).toBe(true);
+
+ expect(mori.clj_to_js(clj_map)).toEqual(js_obj);
+
+ expect(mori.clj_to_js(clj_vec)).toEqual(js_arr);
+
+ });
+
+});
View
@@ -124,4 +124,7 @@
(f x)))
(def ^:export identity cljs.core/identity)
-(def ^:export constantly cljs.core/constantly)
+(def ^:export constantly cljs.core/constantly)
+
+(def ^:export clj-to-js cljs.core/clj->js)
+(def ^:export js-to-clj cljs.core/js->clj)

0 comments on commit 9969795

Please sign in to comment.