From 7244ffc25d868184a6da969dc9cda6776c8f637b Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Sat, 22 Nov 2014 11:08:17 +0100 Subject: [PATCH] Add test for wrap --- test/testcursor.cljs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/testcursor.cljs b/test/testcursor.cljs index f3cad5a..ef21db4 100644 --- a/test/testcursor.cljs +++ b/test/testcursor.cljs @@ -289,3 +289,18 @@ (reset! c3 "foo") (is (= @a {:foo "bar" :foobar "foo"})))) + +(deftest test-wrap + (let [a (atom {:foo "bar"}) + w (r/wrap (:foo @a) swap! a assoc :foo)] + (is (= @w "bar")) + (is (= w (r/wrap "bar" swap! a assoc :foo))) + (is (not= w (r/wrap "foobar" swap! a assoc :foo))) + (is (not= w (r/wrap "bar" swap! a assoc :foobar))) + (is (not= w (r/wrap "bar" reset! a assoc :foo))) + + (reset! w "foobar") + (is (= @w "foobar")) + (is (= @a {:foo "foobar"})) + (is (not= w (r/wrap "bar" swap! a assoc :foo))) + (is (not= w (r/wrap "foobar" swap! a assoc :foo)))))