mirror of https://github.com/status-im/reagent.git
Check for memory leaks
This commit is contained in:
parent
00b5c1d330
commit
a28dc812ae
|
@ -309,7 +309,8 @@
|
||||||
(deftest cursor-values
|
(deftest cursor-values
|
||||||
(let [test-atom (atom {:a {:b {:c {:d 1}}}})
|
(let [test-atom (atom {:a {:b {:c {:d 1}}}})
|
||||||
test-cursor (r/cursor [:a :b :c :d] test-atom)
|
test-cursor (r/cursor [:a :b :c :d] test-atom)
|
||||||
test-cursor2 (r/cursor [] test-atom)] ;; nasty edge case
|
test-cursor2 (r/cursor [] test-atom)
|
||||||
|
runs (running)] ;; nasty edge case
|
||||||
|
|
||||||
;; get the initial values
|
;; get the initial values
|
||||||
(is (= (get-in @test-atom [:a :b :c :d])
|
(is (= (get-in @test-atom [:a :b :c :d])
|
||||||
|
@ -339,13 +340,16 @@
|
||||||
(swap! test-cursor2 assoc :z 3)
|
(swap! test-cursor2 assoc :z 3)
|
||||||
(is (= @test-cursor2 {:z 3}))
|
(is (= @test-cursor2 {:z 3}))
|
||||||
(is (= (get-in @test-atom [])
|
(is (= (get-in @test-atom [])
|
||||||
{:z 3}))))
|
{:z 3}))
|
||||||
|
|
||||||
|
(is (= runs (running)))))
|
||||||
|
|
||||||
|
|
||||||
(deftest atom-behaviors
|
(deftest atom-behaviors
|
||||||
(let [test-atom (atom {:a {:b {:c {:d 1}}}})
|
(let [test-atom (atom {:a {:b {:c {:d 1}}}})
|
||||||
test-cursor (r/cursor [:a :b :c :d] test-atom)
|
test-cursor (r/cursor [:a :b :c :d] test-atom)
|
||||||
witness (atom nil)]
|
witness (atom nil)
|
||||||
|
runs (running)]
|
||||||
;; per the description, reset! should return the new values
|
;; per the description, reset! should return the new values
|
||||||
(is (= {}
|
(is (= {}
|
||||||
(reset! test-cursor {})))
|
(reset! test-cursor {})))
|
||||||
|
@ -365,8 +369,10 @@
|
||||||
(is (= @(:ref @witness) @test-cursor))
|
(is (= @(:ref @witness) @test-cursor))
|
||||||
(is (= (:old @witness) "old"))
|
(is (= (:old @witness) "old"))
|
||||||
(is (= (:new @witness) "new"))
|
(is (= (:new @witness) "new"))
|
||||||
|
|
||||||
;; can we remove the watch?
|
;; can we remove the watch?
|
||||||
(remove-watch test-cursor :w)
|
(remove-watch test-cursor :w)
|
||||||
(reset! test-cursor "removed")
|
(reset! test-cursor "removed")
|
||||||
(is (= (:new @witness) "new")) ;; shouldn't have changed
|
(is (= (:new @witness) "new")) ;; shouldn't have changed
|
||||||
|
(is (= (running) runs))
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue