Add a couple of more tests for with-let

This commit is contained in:
Dan Holmsand 2015-09-23 15:55:57 +02:00
parent 51163c1d07
commit 119fbfe173
1 changed files with 27 additions and 0 deletions

View File

@ -585,3 +585,30 @@
(r/flush)
(is (= [1 2 0] [@n1 @n2 @n3]))))
(is (= [1 2 1] [@n1 @n2 @n3]))))
(deftest with-let-destroy-only
(let [n1 (atom 0)
n2 (atom 0)
c (fn []
(with-let []
(swap! n1 inc)
[:div]
(finally
(swap! n2 inc))))]
(with-mounted-component [c]
(fn [_ div]
(is (= [1 0] [@n1 @n2]))))
(is (= [1 1] [@n1 @n2]))))
(deftest with-let-non-reactive
(let [n1 (atom 0)
n2 (atom 0)
n3 (atom 0)
c (fn []
(with-let [a (swap! n1 inc)]
(swap! n2 inc)
[:div a]
(finally
(swap! n3 inc))))]
(is (= (rstr [c]) (rstr [:div 1])))
(is (= [1 1 1] [@n1 @n2 @n3]))))