Liking cljdoc? Tell your friends :D

me.pmatiello.mockfn.plain


invokeclj

(invoke func)

Marks a function to be dynamically invoked on mock calls. Matching calls will invoke the function with the received arguments and return the output.

Example:

(providing
  [(one-fn :invoke-fn) (invoke identity)]
  (is (= :invoke-fn (one-fn :invoke-fn))))
Marks a function to be dynamically invoked on mock calls. Matching calls
will invoke the function with the received arguments and return the output.

Example:
```
(providing
  [(one-fn :invoke-fn) (invoke identity)]
  (is (= :invoke-fn (one-fn :invoke-fn))))
```
sourceraw docstring

providingcljmacro

(providing bindings & body)

Replaces functions with mocks. These mocks return preconfigured values when called with the expected arguments.

(providing
  [(fn-name &args) return-value
   ...]
  test-body)

Example:

(providing
  [(one-fn) :result]
  (is (= :result (one-fn))))
Replaces functions with mocks. These mocks return preconfigured values when
called with the expected arguments.

```
(providing
  [(fn-name &args) return-value
   ...]
  test-body)
```

Example:
```
(providing
  [(one-fn) :result]
  (is (= :result (one-fn))))
```
sourceraw docstring

raiseclj

(raise exception)

Creates a mock behavior that throws the given exception when the mock is called.

This can be used to simulate error scenarios in tests by configuring a mock to throw a specific exception.

Example:

(providing
  [(one-fn) (raise (ex-info "error!" {}))]
  (is (thrown-with-msg? ExceptionInfo #"error!" (one-fn))))
Creates a mock behavior that throws the given exception when the mock is called.

This can be used to simulate error scenarios in tests by configuring a mock
to throw a specific exception.

Example:
```
(providing
  [(one-fn) (raise (ex-info "error!" {}))]
  (is (thrown-with-msg? ExceptionInfo #"error!" (one-fn))))
```
sourceraw docstring

verifyingcljmacro

(verifying bindings & body)

Replaces functions with mocks. Verifies that a calls where performed the expected number of times.

(verifying
  [(fn-name &args) return-value call-count-matcher
   ...]
  test-body)

Example:

(verifying
  [(one-fn :argument) :result (exactly 1)]
  (is (= :result (one-fn :argument))))
Replaces functions with mocks. Verifies that a calls where performed the
expected number of times.

```
(verifying
  [(fn-name &args) return-value call-count-matcher
   ...]
  test-body)
```

Example:
```
(verifying
  [(one-fn :argument) :result (exactly 1)]
  (is (= :result (one-fn :argument))))
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close