Add test for wrap

This commit is contained in:
Dan Holmsand 2014-11-22 11:08:17 +01:00
parent f94fcd5542
commit 7244ffc25d
1 changed files with 15 additions and 0 deletions

View File

@ -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)))))