Fork me on GitHub
#testing
<
2021-05-23
>
mbertheau05:05:51

Is there a solution out there for testing intermediate values in a threading macro? I.e. I want to write something like:

(-> [{:id 1}]
    (click 1)
    (is {:id 1 :selected? true})
    (click 1)
    (is {:id 1 :selected? false}))

plexus06:05:40

doto won't really work because of the nesting, but just create your own helpers

(let [assert-selected #(do (is (= %1 {:id 1 :selected? %2})) %1)]
  (-> [{:id 1}]
    (click 1)
    (assert-selected true)
    (click 1)
    (assert-selected false)))