Enzyme.Wrapper
- Package
- purescript-react-enzyme
- Repository
- alvart/purescript-react-enzyme
#Wrapper Source
class Wrapper w where
The Wrapper
type class represents any Enzyme wrapper of React components
with an interface to manipulate or traverse them.
Members
at :: Int -> w -> Effect w
children :: w -> Effect w
Returns a new wrapper with all of the children of the node(s) in the current wrapper.
debug :: { ignoreProps :: Boolean, verbose :: Boolean } -> w -> Effect String
Returns an HTML-like string of the wrapper for debugging purposes. Useful to print out to the console when tests are not passing when you expect them to.
findWhere :: (w -> Effect Boolean) -> w -> Effect w
Finds every node in the render tree that returns true for the provided predicate function.
forEach :: (w -> Int -> Effect Unit) -> w -> Effect Unit
Maps the current array of nodes to another array. Each node is passed in as a wrapper to the map function.
get :: Int -> w -> Effect ReactElement
Returns the node at a given index of the current wrapper.
hostNodes :: w -> Effect w
Returns a new wrapper with only host nodes. When using React-dom, host nodes are HTML elements rather than custom React components, e.g.
<div>
versus<MyComponent>
.invoke :: String -> w -> Array Foreign -> Effect Unit
Invokes a property as a function with an Array of arguments.
is :: String -> w -> Effect Boolean
Returns whether or not the single wrapped node matches the provided selector. It must be a single-node wrapper.
length :: w -> Effect Int
Returns the number of nodes inside the current wrapper.
matches :: ReactElement -> w -> Effect Boolean
Returns whether or not a patternNode React element matches any element in the render tree. It must be a single-node wrapper, and only the root node is checked.
name :: w -> Effect String
Returns the name of the current node of this wrapper. If it's a composite component, this will be the name of the component. If it's a native DOM it will be a string of the tag name.
parents :: w -> Effect w
Returns a wrapper around all of the parents/ancestors of the single node in the wrapper. Does not include the node itself.
property :: String -> w -> Effect Foreign
Returns the prop value for the root node of the wrapper with the provided key. It must be a single-node wrapper.
reduce :: forall a. (a -> w -> Int -> Effect a) -> a -> w -> Effect a
Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node is passed in as a wrapper, and is processed from left to right.
setProperty :: String -> Foreign -> w -> Aff Unit
A method that sets the property of the root component, and re-renders. Useful for when you are wanting to test how the component behaves over time with changing props. Blocks until the operation completes.
slice :: Int -> Int -> w -> Effect w
Returns a new wrapper with a subset of the nodes of the original wrapper, according to the rules of
Array#slice
.text :: w -> Effect String
Returns a string of the rendered text of the current render tree.
unmount :: w -> Effect Unit
A method that unmounts the component. This can be used to simulate a component going through an unmount/mount lifecycle.
Returns a wrapper around the node at a given index of the current wrapper.