Liking cljdoc? Tell your friends :D

reacl2.test-util.beta


*max-update-loops*cljs

source

envcljs

(env class & [options])

Returns a fresh test environment for testing the given class. An options map may include a :create-node-mock function that is called with a React test renderer instance and may return a value that is then used for reacl2.core/get-dom on references.

Returns a fresh test environment for testing the given class. An
`options` map may include a `:create-node-mock` function that is
called with a React test renderer instance and may return a value
that is then used for [[reacl2.core/get-dom]] on references.
sourceraw docstring

env?cljs

(env? v)

Returns true if the given value is a test environment.

Returns true if the given value is a test environment.
sourceraw docstring

fn-envcljs

(fn-env f & [options])

Returns a test environment for tests of the given function, which must return a dom element or class instance. For options see env.

Returns a test environment for tests of the given function, which
must return a dom element or class instance. For `options` see [[env]].
sourceraw docstring

get-componentcljs

(get-component env)

Return the component currently mounted in the given test environment. Throws if it is not mounted. Note that the returned component becomes invalid after the next call to mount! or unmount!, but stays valid after an update!.

Return the component currently mounted in the given test
environment. Throws if it is not mounted. Note that the returned
component becomes invalid after the next call to [[mount!]]
or [[unmount!]], but stays valid after an [[update!]].
sourceraw docstring

inject-action!cljs

(inject-action! comp action)

This injects or simulates a (return :action action) from a method of the class the given component was instantied from. Returns a changed app-state and actions from the toplevel class, in the form of a reacl/return value.

This injects or simulates a `(return :action action)` from a
method of the class the given component was instantied from. Returns
a changed app-state and actions from the toplevel class, in the form
of a `reacl/return` value.
sourceraw docstring

inject-action!!cljs

(inject-action!! comp action)

Like inject-action!, but followed by a push!!.

Like [[inject-action!]], but followed by a [[push!!]].
sourceraw docstring

inject-change!cljs

(inject-change! comp state)

This injects or simulates a (return :app-state state) from a method of the class the given component was instantied from. Returns a changed app-state and actions from the toplevel class, in the form of a reacl/return value.

This injects or simulates a `(return :app-state state)` from a
method of the class the given component was instantied from. Returns
a changed app-state and actions from the toplevel class, in the form
of a `reacl/return` value.
sourceraw docstring

inject-change!!cljs

(inject-change!! comp state)

Like inject-change!, but followed by a push!!.

Like [[inject-change!]], but followed by a [[push!!]].
sourceraw docstring

inject-local-state!cljs

(inject-local-state! comp state)
(inject-local-state! env state)

Sets the local-state of a component, or the toplevel component currently mounted in the given test environment. Returns a changed app-state and actions returned from the toplevel class as a result, in the form of a reacl/return value. Throws if it is not mounted.

Note that it is a bit dangerous to base tests on this, and should only be used with care, if the way to get to this state is otherwise impossible in a unit test.

Sets the local-state of a component, or the toplevel component
currently mounted in the given test environment. Returns a changed
app-state and actions returned from the toplevel class as a result,
in the form of a `reacl/return` value. Throws if it is not mounted.

Note that it is a bit dangerous to base tests on this, and should
only be used with care, if the way to get to this state is otherwise
impossible in a unit test.
sourceraw docstring

inject-return!cljs

(inject-return! comp ret)

This injects or simulates a [[reacl/return]] from a method of the class the given component was instantied from. Returns a changed app-state and actions from the toplevel class, in the form of a reacl/return value.

This injects or simulates a [[reacl/return]] from a method of the
class the given component was instantied from. Returns a
changed app-state and actions from the toplevel class, in the form
of a `reacl/return` value.
sourceraw docstring

inject-return!!cljs

(inject-return!! comp ret)

Like inject-return!, but followed by a push!!.

Like [[inject-return!]], but followed by a [[push!!]].
sourceraw docstring

inspect-local-statecljs

(inspect-local-state comp)
(inspect-local-state env)

Return the current local-state of a component, or if given a test environment, of the toplevel component. Throws if it is not mounted.

Return the current local-state of a component, or if
given a test environment, of the toplevel component. Throws if it is
not mounted.
sourceraw docstring

invoke-callback!cljs

(invoke-callback! elem callback event)

Invokes the function assiciated with the given callback of the given dom element (e.g. :onclick) with the given event object, and returns a changed app-state and actions from the toplevel class, in the form of a reacl/return value. Typically, you will first search for the element via xpath/select-one.

Note that this does not do a 'real' DOM event dispatching, e.g. no bubbling or canceling phase, and no default effects.

Invokes the function assiciated with the given `callback` of the
given dom element (e.g. `:onclick`) with the given event object, and
returns a changed app-state and actions from the toplevel class, in
the form of a `reacl/return` value. Typically, you will first search for
the element via [[xpath/select-one]].

Note that this does not do a 'real' DOM event dispatching, e.g. no
bubbling or canceling phase, and no default effects.
sourceraw docstring

invoke-callback!!cljs

(invoke-callback!! elem callback event)

Like invoke-callback!, but followed by a push!!.

Like [[invoke-callback!]], but followed by a [[push!!]].
sourceraw docstring

is-mounted?cljs

(is-mounted? env)

Returns if the given testing environment contains a mounted component (true between mount! and unmount!).

Returns if the given testing environment contains a mounted component (true between [[mount!]] and [[unmount!]]).
sourceraw docstring

mountcljs

(mount class & args)
(mount class app-state & args)

Mounts an instance of the given class into a fresh test environment, and returns the component.

Mounts an instance of the given class into a fresh test environment, and returns the component.
sourceraw docstring

mount!cljs

(mount! env & args)
(mount! env app-state & args)

Does a fresh mount of the class from the given testing environment with the given app-state and args, returning app-state changes and actions returned by the class in form of a reacl/return value.

Does a fresh mount of the class from the given testing
environment with the given app-state and args, returning app-state
changes and actions returned by the class in form of a
`reacl/return` value.
sourceraw docstring

mount!!cljs

(mount!! env & args)

Like mount!, but followed by a push!!.

Like [[mount!]], but followed by a [[push!!]].
sourceraw docstring

mount-ignorecljs

(mount-ignore class & args)
(mount-ignore class app-state & args)

Like mount, mounts an instance of the given class into a fresh test environment, and returns the component, but does not issue a warning when the class returned something on mount.

Like [[mount]], mounts an instance of the given class into a fresh
test environment, and returns the component, but does not issue a
warning when the class returned something on mount.
sourceraw docstring

providedcljmacro

(provided bindings & body)

This replaces the values bound to the given vars during the evaluation of body, and sets them back to the previous values afterwards. Example:

(def x 42)
(provided [x 11]
  (is (= (* x 2) 22)))
(is (= x 42))

You can use this to isolate a test of one class from the implementation of another class used in it, by replacing it with a mock. Do this only if isolating the test via inject-return! is not enough.

This replaces the values bound to the given vars during the
evaluation of `body`, and sets them back to the previous values
afterwards. Example:

```
(def x 42)
(provided [x 11]
  (is (= (* x 2) 22)))
(is (= x 42))
```

You can use this to isolate a test of one class from the
implementation of another class used in it, by replacing it with a mock.
Do this only if isolating the test via [[inject-return!]] is not enough.
sourceraw docstring

push!cljs

(push! env ret)

If the given 'return' value contains an app-state change, then update the given test environment, merging in another 'return' value resulting from the update - 'pushing' the update cycle forward.

If the given 'return' value contains an app-state change, then
update the given test environment, merging in another 'return' value
resulting from the update - 'pushing' the update cycle forward.
sourceraw docstring

push!!cljs

(push!! env ret)

If the given 'return' value contains an app-state change, then update the given test environment, merging in another 'return' value resulting from the update, and repeat until the app-state does not change anymore. Stops with an exception when *max-update-loops* are exceeded.

If the given 'return' value contains an app-state change, then
update the given test environment, merging in another 'return' value
resulting from the update, and repeat until the app-state does not
change anymore. Stops with an exception when [[*max-update-loops*]]
are exceeded.
sourceraw docstring

send-message!cljs

(send-message! env msg)
(send-message! comp msg)

Sends the given message to the given component, or the component currently mounted in the given test environment. Returns a changed app-state and actions from the toplevel class, in the form of a reacl/return value. Throws if it is not mounted.

Sends the given message to the given component, or the component
currently mounted in the given test environment. Returns a changed
app-state and actions from the toplevel class, in the form of a
`reacl/return` value. Throws if it is not mounted.
sourceraw docstring

send-message!!cljs

(send-message!! c msg)

Like send-message!, but followed by a push!!.

Like [[send-message!]], but followed by a [[push!!]].
sourceraw docstring

unmount!cljs

(unmount! env)

Performs an unmount of the component mounted in the given test environment. Returns a changed app-state and actions from the class, in the form of a reacl/return value.

Performs an unmount of the component mounted in the given test
environment. Returns a changed app-state and actions from the class,
in the form of a `reacl/return` value.
sourceraw docstring

unmount!!cljs

(unmount!! env)

Like unmount!, but followed by a push!!.

Like [[unmount!]], but followed by a [[push!!]].
sourceraw docstring

update!cljs

(update! comp & args)
(update! env & args)
(update! comp app-state & args)
(update! env app-state & args)

Performs an update of the given toplevel component, or the toplevel component currently mounted in the given test environment. Returns a changed app-state and actions from the toplevel class, in the form of a reacl/return value.

Performs an update of the given toplevel component, or the toplevel
component currently mounted in the given test environment. Returns a
changed app-state and actions from the toplevel class, in the form
of a `reacl/return` value.
sourceraw docstring

update!!cljs

(update!! c & args)

Like update!!, but followed by a push!!.

Like [[update!!]], but followed by a [[push!!]].
sourceraw docstring

with-component-returncljs

(with-component-return comp f & args)
(with-component-return env f & args)

Calls (f comp & args) if called with a component, or if called with a test environment, with the currently mounted toplevel class instance. In any case, after f has been evaluated for its side-effects, this returns what has been returned from the tested toplevel class in the form of a reacl/return value.

Note that will usually not need to call this function directly; use the various utilities from this module to interact with a component.

Calls `(f comp & args)` if called with a component, or if
called with a test environment, with the currently mounted toplevel
class instance. In any case, after `f` has been evaluated for its
side-effects, this returns what has been returned from the tested
toplevel class in the form of a `reacl/return` value.

Note that will usually not need to call this function directly; use
the various utilities from this module to interact with a
component.
sourceraw docstring

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

× close