Skip to content

Commit

Permalink
Test Cache ony in cljs environment.
Browse files Browse the repository at this point in the history
Change-Id: I161cc6a20dde9f7dbe7e83574c0c529edcfc9835
  • Loading branch information
grzm committed Nov 16, 2016
1 parent 5e1af73 commit 98cc620
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/test/om/next/tests.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1057,25 +1057,26 @@
(is (not (contains? (get t-err 'this/throws) :result)))
(is (= (get (om/transact! r '[(this/throws) :app/count]) :app/count) 2))))

(deftest test-cache-clear
(let [r (om/reconciler {:state (atom {:app/count 0})
:parser p})
h (get-in r [:config :history])]
(is (= 0 (count @(.-index h))))
(is (= 0 (count (.-arr h))))
(om/transact! r '[(app/inc!)])
(let [h (get-in r [:config :history])]
(is (= 1 (count @(.-index h))))
(is (= 1 (count (.-arr h)))))
(let [r' (update-in r [:config :history] #(.clear %))
h' (get-in r' [:config :history])]
(is (= {} @(.-index h')))
(is (= 0 (count (.-arr h'))))
(is (= [] (js->clj (.-arr h')))))
(om/transact! r '[(app/inc!)])
(let [h (get-in r [:config :history])]
(is (= 1 (count @(.-index h))))
(is (= 1 (count (.-arr h)))))))
#?(:cljs
(deftest test-cache-clear
(let [r (om/reconciler {:state (atom {:app/count 0})
:parser p})
h (get-in r [:config :history])]
(is (= 0 (count @(.-index h))))
(is (= 0 (count (.-arr h))))
(om/transact! r '[(app/inc!)])
(let [h (get-in r [:config :history])]
(is (= 1 (count @(.-index h))))
(is (= 1 (count (.-arr h)))))
(let [r' (update-in r [:config :history] #(.clear %))
h' (get-in r' [:config :history])]
(is (= {} @(.-index h')))
(is (= 0 (count (.-arr h'))))
(is (= [] (js->clj (.-arr h')))))
(om/transact! r '[(app/inc!)])
(let [h (get-in r [:config :history])]
(is (= 1 (count @(.-index h))))
(is (= 1 (count (.-arr h))))))))

;; -----------------------------------------------------------------------------
;; Recursive Parsing
Expand Down

0 comments on commit 98cc620

Please sign in to comment.