Liking cljdoc? Tell your friends :D

reacl2.test-util.xpath

cljs

An xpath is basically a convenient and compositional way to define a filter function on nodes in a virtual DOM tree, resp. the React test renderer tree, roughly based on a 'path' through the tree.

The functions select, select-all, select-one and contains? apply that filter, starting from a specific context node.

For example:

(require [reacl2.test-util.xpath :as xp :include-macros true])

(>> / ** "div" [xp/text (xp/is= "Hello")])

matches on all div elements anywhere below the context node, that have a text content equal to "Hello".

(>> / my-class / "span" [:id (xp/is= "foo")])

matches on all span children of instances of the class my-class below the context node, that have the id "foo".

(>> my-class [xp/args (xp/is? = [42])])

matches the context node, if it is an instance of my-class and if its argument vector equals [42].

(>> / "span" [xp/first])

matches the first span element below the context node.

An xpath is basically a convenient and compositional way to define
  a filter function on nodes in a virtual DOM tree, resp. the React
  test renderer tree, roughly based on a 'path' through the tree.

  The functions [[select]], [[select-all]], [[select-one]]
  and [[contains?]] apply that filter, starting from a specific
  _context node_.

  For example:

```
(require [reacl2.test-util.xpath :as xp :include-macros true])

(>> / ** "div" [xp/text (xp/is= "Hello")])
```

  matches on all `div` elements anywhere below the context node, that have a text content equal to `"Hello"`.

```
(>> / my-class / "span" [:id (xp/is= "foo")])
```

  matches on all `span` children of instances of the class `my-class` below the context node, that have the id `"foo"`.

```
(>> my-class [xp/args (xp/is? = [42])])
```

  matches the context node, if it is an instance of `my-class` and if its argument vector equals `[42]`.

```
(>> / "span" [xp/first])
```

  matches the first span element below the context node.
raw docstring

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

× close