Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1669 instance docs #1714

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions docs/api/ReactWrapper/getNode.md

This file was deleted.

32 changes: 0 additions & 32 deletions docs/api/ReactWrapper/getNodes.md

This file was deleted.

6 changes: 2 additions & 4 deletions docs/api/ReactWrapper/instance.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# `.instance() => ReactComponent`

Gets the instance of the component being rendered as the root node passed into `mount()`.

NOTE: can only be called on a wrapper instance that is also the root instance.
Returns the wrapper's underlying instance.



#### Returns

`ReactComponent`: The component instance.
`ReactComponent|DOMComponent`: The retrieved instance.



Expand Down
10 changes: 2 additions & 8 deletions docs/api/mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ Returns a static HTML rendering of the current node.
#### [`.get(index) => ReactElement`](ReactWrapper/get.md)
Returns the node at the provided index of the current wrapper.

#### [`.getNode() => ReactElement`](ReactWrapper/getNode.md)
Returns the wrapper's underlying node.

#### [`.getNodes() => Array<ReactElement>`](ReactWrapper/getNodes.md)
Returns the wrapper's underlying nodes.

#### [`.getDOMNode() => DOMComponent`](ReactWrapper/getDOMNode.md)
Returns the outer most DOMComponent of the current wrapper.

Expand Down Expand Up @@ -174,8 +168,8 @@ Manually sets props of the root component.
#### [`.setContext(context) => ReactWrapper`](ReactWrapper/setContext.md)
Manually sets context of the root component.

#### [`.instance() => ReactComponent`](ReactWrapper/instance.md)
Returns the instance of the root component.
#### [`.instance() => ReactComponent|DOMComponent`](ReactWrapper/instance.md)
Returns the wrapper's underlying instance.

#### [`.unmount() => ReactWrapper`](ReactWrapper/unmount.md)
A method that un-mounts the component.
Expand Down
6 changes: 2 additions & 4 deletions packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,15 @@ class ReactWrapper {
}

/**
* Gets the instance of the component being rendered as the root node passed into `mount()`.
*
* NOTE: can only be called on a wrapper instance that is also the root instance.
* Returns the wrapper's underlying instance.
*
* Example:
* ```
* const wrapper = mount(<MyComponent />);
* const inst = wrapper.instance();
* expect(inst).to.be.instanceOf(MyComponent);
* ```
* @returns {ReactComponent}
* @returns {ReactComponent|DOMComponent}
*/
instance() {
if (this.length !== 1) {
Expand Down