Add tests for new "on-changes" middleware
This commit is contained in:
parent
82b3c87f80
commit
c2a9a041eb
|
@ -29,3 +29,13 @@
|
|||
handler) db [nil])]
|
||||
(is (= (:a new-db)
|
||||
false)))))
|
||||
|
||||
|
||||
(deftest on-changes
|
||||
(let [set-a (fn [db v] (assoc db :a v)) ;; handler
|
||||
mid-ware (middleware/on-changes + [:c] [:a] [:b]) ;; middleware
|
||||
wrapped (mid-ware set-a)] ;; wrapped middleware
|
||||
(is (= (wrapped {:a 0 :b 2} 0) ;; no change in 'a'
|
||||
{:a 0 :b 2}))
|
||||
(is (= ({:a 4 :b 2} 0) ;; 'a' changed to 0
|
||||
{:c 2 :a 0 :b 2})))) ;; 'c' is a + b
|
Loading…
Reference in New Issue