Skip to content

Commit

Permalink
[Docs] mount: add missing getElement/getElements docs
Browse files Browse the repository at this point in the history
Fixes #2574
  • Loading branch information
ljharb committed Dec 20, 2022
1 parent 9bb92eb commit a4980e1
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/api/ReactWrapper/getElement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# `.getElement() => ReactElement`

Returns the wrapped ReactElement.

If the current wrapper is wrapping the root component, returns the root component's latest render output.


#### Returns

`ReactElement`: The retrieved ReactElement.



#### Examples

```jsx
const element = (
<div>
<span />
<span />
</div>
);

function MyComponent() {
return element;
}

const wrapper = mount(<MyComponent />);
expect(wrapper.getElement()).to.equal(element);
```



#### Related Methods

- [`.getElements() => Array<ReactElement>`](getElements.md)
37 changes: 37 additions & 0 deletions docs/api/ReactWrapper/getElements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# `.getElements() => Array<ReactElement>`

Returns the wrapped ReactElements

If the current wrapper is wrapping the root component, returns the root component's latest render output wrapped in an array.


#### Returns

`Array<ReactElement>`: The retrieved ReactElements.



#### Examples

```jsx
const one = <span />;
const two = <span />;

function Test() {
return (
<div>
{one}
{two}
</div>
);
}

const wrapper = mount(<Test />);
expect(wrapper.find('span').getElements()).to.deep.equal([one, two]);
```



#### Related Methods

- [`.getElement() => ReactElement`](getElement.md)
6 changes: 6 additions & 0 deletions docs/api/mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ Returns the node at the provided index of the current wrapper.
#### [`.getDOMNode() => DOMComponent`](ReactWrapper/getDOMNode.md)
Returns the outer most DOMComponent of the current wrapper.

#### [`.getElement() => ReactElement`](ReactWrapper/getElement.md)
Returns the wrapped ReactElement.

#### [`.getElements() => Array<ReactElement>`](ReactWrapper/getElements.md)
Returns the wrapped ReactElements.

#### [`.at(index) => ReactWrapper`](ReactWrapper/at.md)
Returns a wrapper of the node at the provided index of the current wrapper.

Expand Down

0 comments on commit a4980e1

Please sign in to comment.