File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1010 (swap! index assoc id x')))
1111 (.push arr id))
1212 (get [this id]
13- (get @index id)))
13+ (get @index id))
14+ (clear [this]
15+ (reset! (.-index this) {})
16+ (set! (.-arr this) #js [])
17+ this))
1418
1519(defn cache [size]
1620 (Cache. #js [] (atom {}) size))
Original file line number Diff line number Diff line change 10571057 (is (not (contains? (get t-err 'this/throws) :result )))
10581058 (is (= (get (om/transact! r '[(this/throws ) :app/count ]) :app/count ) 2 ))))
10591059
1060+ #?(:cljs
1061+ (deftest test-cache-clear
1062+ (let [r (om/reconciler {:state (atom {:app/count 0 })
1063+ :parser p})
1064+ h (get-in r [:config :history ])]
1065+ (is (= 0 (count @(.-index h))))
1066+ (is (= 0 (count (.-arr h))))
1067+ (om/transact! r '[(app/inc! )])
1068+ (let [h (get-in r [:config :history ])]
1069+ (is (= 1 (count @(.-index h))))
1070+ (is (= 1 (count (.-arr h)))))
1071+ (let [r' (update-in r [:config :history ] #(.clear %))
1072+ h' (get-in r' [:config :history ])]
1073+ (is (= {} @(.-index h')))
1074+ (is (= 0 (count (.-arr h'))))
1075+ (is (= [] (js->clj (.-arr h')))))
1076+ (om/transact! r '[(app/inc! )])
1077+ (let [h (get-in r [:config :history ])]
1078+ (is (= 1 (count @(.-index h))))
1079+ (is (= 1 (count (.-arr h))))))))
1080+
10601081; ; -----------------------------------------------------------------------------
10611082; ; Recursive Parsing
10621083
You can’t perform that action at this time.
0 commit comments