This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-09
Channels
- # admin-announcements (1)
- # boot (225)
- # braid-chat (1)
- # cider (25)
- # cljs-dev (35)
- # cljsrn (1)
- # clojars (6)
- # clojure (81)
- # clojure-berlin (1)
- # clojure-dev (21)
- # clojure-france (2)
- # clojure-japan (6)
- # clojure-poland (1)
- # clojure-russia (10)
- # clojure-uk (3)
- # clojurescript (121)
- # code-reviews (1)
- # core-async (4)
- # core-logic (2)
- # cursive (15)
- # datomic (8)
- # hoplon (4)
- # jaunt (112)
- # jobs-discuss (35)
- # om (41)
- # parinfer (8)
- # re-frame (3)
- # reagent (4)
- # ring (2)
- # untangled (38)
I'm setting up unit tests for my handler functions, and I realized that I'm not sure how to test a handler which dispatches further events. Pure handlers are easy: they simply take the app db and return a changed one. Handlers with side effects are not too hard as long as I can with-redefs
the side-effecting function and assert that it was called correctly (and test the real version somewhere else).
But a handler which conditionally dispatches other events seems trickier. Maybe I should be using with-redefs
on dispatch
itself, and just assert that it's trying to dispatch the right event...?
...yeah, that's actually going to work. Thanks! :rubber_duck:
(with-redefs [re-frame.core/dispatch (fn [[event-type & args]] ...)] ...)