Liking cljdoc? Tell your friends :D

reacl2.test-util

Various testing utilities for Reacl.

Various testing utilities for Reacl.
raw docstring

->path-elementcljs

(->path-element x)
source

->path-element-typecljs

(->path-element-type x)
source

aftercljs

(after message & checks)

Creates an interaction the sends the given message to the tested component, and performs the given checks afterwards. Should be used in the context a [[testing-class*]] call.

Creates an interaction the sends the given message to the tested
component, and performs the given checks afterwards. Should be used
in the context a [[testing-class*]] call.
sourceraw docstring

create-renderercljs

(create-renderer)

Create a shallow renderer for testing

Create a shallow renderer for testing
sourceraw docstring

descend-into-elementcljs

(descend-into-element element path)
source

dom=?cljs

(dom=? el1 el2)

Compare two React DOM elements for equality.

Compare two React DOM elements for equality.
sourceraw docstring

element-childrencljs

(element-children element)

Get the children of a rendered element as a vector.

Get the children of a rendered element as a vector.
sourceraw docstring

element-has-type?cljs

(element-has-type? element tag)

Check if an element has a given type, denoted by tag.

tag may be a keyword or string with the name of a DOM element, or React or a Reacl class.

Check if an element has a given type, denoted by `tag`.

`tag` may be a keyword or string with the name of a DOM element,
or React or a Reacl class.
sourceraw docstring

handle-messagecljs

(handle-message cl app-state args local-state msg)

Invoke the message handler of a Reacl element.

  • cl is the Reacl class.
  • app-state is the app state
  • local-state is the local state
  • msg is the message.

This returns a pair [cmp ret] where:

  • cmp is the mock component used in the test
  • ret is a Returned record with app-state, local-state, and actions fields.
Invoke the message handler of a Reacl element.

- `cl` is the Reacl class.
- `app-state` is the app state
- `local-state` is the local state
- `msg` is the message.

This returns a pair `[cmp ret]` where:

- `cmp` is the mock component used in the test
- `ret` is  a ``Returned`` record with `app-state`, `local-state`, and `actions` fields.
sourceraw docstring

hiccup-matches?cljs

(hiccup-matches? pattern data)
source

instantiate&mountcljs

(instantiate&mount clazz & args)
source

invoke-callbackcljs

(invoke-callback element callback event)

Invoke a callback of an element.

callback must a keyword naming the attribute (onchange).

event must be a React event - don't forget the �#js {...}`

Invoke a callback of an element.

`callback` must a keyword naming the attribute (`onchange`).

`event` must be a React event - don't forget the �#js {...}`
sourceraw docstring

no-checkcljs

An empty check that does nothing.

An empty check that does nothing.
sourceraw docstring

path-element-matches?cljs

(path-element-matches? path-element element)
source

PathElementcljs

source

render!cljs

(render! renderer el)

Render an element into a renderer.

Render an element into a renderer.
sourceraw docstring

render->hiccupcljs

(render->hiccup element)
source

render-outputcljs

(render-output renderer)

Get the output of rendering.

Get the output of rendering.
sourceraw docstring

render-shallowlycljs

(render-shallowly element)
(render-shallowly element renderer)

Render an element shallowly.

Render an element shallowly.
sourceraw docstring

render-to-textcljs

(render-to-text dom)
source

rendered-childrencljs

(rendered-children element)

Retrieve children from a rendered element.

Retrieve children from a rendered element.
sourceraw docstring

simulatecljs

(simulate f & checks)

Creates an interaction, that will call f with the ReactTestUtils.Simulate object and the dom node of the tested component. The simulator object has methods like click that you can call to dispatch a DOM event. The given checks are performed afterwards.

Creates an interaction, that will call `f` with the
ReactTestUtils.Simulate object and the dom node of the
tested component. The simulator object has methods like `click` that
you can call to dispatch a DOM event. The given checks are performed
afterwards.
sourceraw docstring

the-app-statecljs

(the-app-state f)

Create a check on the app-state, by calling the given function f with the app-state at that time. Should be used in the context a [[testing-class*]] call.

Create a check on the app-state, by calling the given function f
with the app-state at that time. Should be used in the context a
[[testing-class*]] call.
sourceraw docstring

the-domcljs

(the-dom f)

Create a check on the dom rendered by a component, by calling the given function f with the dom-node at that time. Should be used in the context a [[testing-class*]] call.

Create a check on the dom rendered by a component, by calling the
given function f with the dom-node at that time. Should be used in
the context a [[testing-class*]] call.
sourceraw docstring

the-local-statecljs

(the-local-state f)

Create a check on the local-state, by calling the given function f with the local-state at that time. Should be used in the context a [[testing-class*]] call.

Create a check on the local-state, by calling the given function f
with the local-state at that time. Should be used in the context a
[[testing-class*]] call.
sourceraw docstring

with-testing-class*cljs

(with-testing-class* [clazz & args] initial-check & interactions)

Instantiates the given class with an initial app-state and arguments, performs the initial-check and all given interactions.

A 'check' is a function taking a function to retrieve the current app-state and a function retrieving the current dom node as rendered by the class - see the-app-state and the-dom to create usual checks.

An 'interaction' is a function taking a function to send a message to the component, and returning a sequence of checks - see after to create a usual interaction.

Note that check implementations should usually contain clojure-test assertions. A common pattern could be:

(with-testing-class* [my-class nil "en"] (the-dom #(is (= "Hello World" (.-innerText %)))) (after (set-lang-message "de") (the-dom #(is (= "Hallo Welt" (.-innerText %))))))

Instantiates the given class with an initial app-state and arguments,
performs the initial-check and all given interactions.

A 'check' is a function taking a function to retrieve the current
app-state and a function retrieving the current dom node as rendered
by the class - see [[the-app-state]] and [[the-dom]] to create usual
checks.

An 'interaction' is a function taking a function to send a
message to the component, and returning a sequence of checks - see
[[after]] to create a usual interaction.

Note that check implementations should usually contain clojure-test
assertions. A common pattern could be:

 (with-testing-class* [my-class nil "en"]
   (the-dom #(is (= "Hello World" (.-innerText %))))
   (after (set-lang-message "de")
          (the-dom #(is (= "Hallo Welt" (.-innerText %))))))
sourceraw docstring

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

× close