A testing framework for stubs, spies and mocks. Enables verification of interactions with a function.
A testing framework for stubs, spies and mocks. Enables verification of interactions with a function.
(call-count f)
Returns the count of the number of calls to the spy f.
Returns the count of the number of calls to the spy f.
(call-matching? f pred)
Returns true if any of the calls to the spy f match the predicate
Returns true if any of the calls to the spy f match the predicate
(called-at-least-n-times? f n)
Returns true if the spy f was called at least n times, false if not.
Returns true if the spy f was called at least n times, false if not.
(called-at-least-once? f)
Returns true if the spy f was called at least once, false if not.
Returns true if the spy f was called at least once, false if not.
(called-n-times? f n)
Returns true if the spy f was called n times, false if not.
Returns true if the spy f was called n times, false if not.
(called-no-more-than-n-times? f n)
Returns true if the spy f was called no more than n times, false if not.
Returns true if the spy f was called no more than n times, false if not.
(called-no-more-than-once? f)
Returns true if the spy f was called once or not at all, false if not.
Returns true if the spy f was called once or not at all, false if not.
(called-once-with? f & args)
Returns true if there was only one call to the spy f and the args match, false if not.
Returns true if there was only one call to the spy f and the args match, false if not.
(called-once? f)
Returns true if the spy f was called once, false if not.
Returns true if the spy f was called once, false if not.
(called-with? f & args)
Returns true if any of the calls to the spy f match the args, false if no calls match.
Returns true if any of the calls to the spy f match the args, false if no calls match.
(called? f)
Returns true is the spy f was called, false if not.
Returns true is the spy f was called, false if not.
(calls f)
Returns a list of all calls to the spy f.
Returns a list of all calls to the spy f.
(first-call f)
Returns the first call to the spy f
Returns the first call to the spy f
(first-response f)
Returns the first response returned by the spy f.
Returns the first response returned by the spy f.
(last-call f)
Returns the last call to the spy f
Returns the last call to the spy f
(last-response f)
Returns the last response returned by the spy f.
Returns the last response returned by the spy f.
(mock f)
An alias for spy, behaviour for the function is provided by the user.
An alias for spy, behaviour for the function is provided by the user.
(not-called-with? f & args)
Returns true if the no calls to the spy f match the args, false if a call matches.
Returns true if the no calls to the spy f match the args, false if a call matches.
(not-called? f)
Returns true if the spy f was never called, false if not.
Returns true if the spy f was never called, false if not.
(nth-call f n)
Returns the nth call to the spy f for the index n.
Returns the nth call to the spy f for the index n.
(nth-response f n)
Returns the response of the spy f at the index n.
Returns the response of the spy f at the index n.
(reset-spy! f)
Resets the calls and responses on the spy f.
Resets the calls and responses on the spy f.
(responses f)
Returns a list of all responses returned by the spy f.
Returns a list of all responses returned by the spy f.
(spy)
(spy f)
If no function is supplied, returns a function that takes any number of args and returns nil.
If a function is supplied, returns a function that wraps the function.
Adds metadata {:calls (atom []) :responses (atom [])} to the function, calls and responses are recorded and stored inside the atoms.
If an exception is thrown by the function this is caught, recorded as a response nested in a map under the key :thrown, and rethrown.
If no function is supplied, returns a function that takes any number of args and returns nil. If a function is supplied, returns a function that wraps the function. Adds metadata {:calls (atom []) :responses (atom [])} to the function, calls and responses are recorded and stored inside the atoms. If an exception is thrown by the function this is caught, recorded as a response nested in a map under the key :thrown, and rethrown.
(stub)
(stub value)
Returns a spy function that returns the value supplied, or nil if no value is supplied.
Returns a spy function that returns the value supplied, or nil if no value is supplied.
(stub-throws exception)
Returns a spy function that throws the exception provided.
Returns a spy function that throws the exception provided.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close