(bind! fn-name mock)
(mocking & args)
Almost the same as with-redefs
, but makes it easy to return different data for every
subsequent call, and also works with async (promise-based) tests. Expects a function
with their specific inputs, and arrow, and the outputs, then a separator ---
, and
the code to which the mock will be applied
(mocking
(+ 1 2) => 4
(+ 3 4) =streams=> [5 6 7]
---
(+ 1 2) ; Will return 4
(+ 3 4) ; Will return 5
(+ 3 4) ; Will return 6
(+ 3 4) ; Will return 7
(+ 3 4)) ; Will crash win an exception
Almost the same as `with-redefs`, but makes it easy to return different data for every subsequent call, and also works with async (promise-based) tests. Expects a function with their specific inputs, and arrow, and the outputs, then a separator `---`, and the code to which the mock will be applied ``` (mocking (+ 1 2) => 4 (+ 3 4) =streams=> [5 6 7] --- (+ 1 2) ; Will return 4 (+ 3 4) ; Will return 5 (+ 3 4) ; Will return 6 (+ 3 4) ; Will return 7 (+ 3 4)) ; Will crash win an exception ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close