From fb19fda855a44b7484b85546713957f8d07a3283 Mon Sep 17 00:00:00 2001 From: Conor Cafferkey Date: Fri, 1 Jun 2018 13:46:00 +0200 Subject: [PATCH] Updated docs for ReactWrapper.instance() #1669 --- docs/api/ReactWrapper/instance.md | 6 ++---- docs/api/mount.md | 4 ++-- packages/enzyme/src/ReactWrapper.js | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/api/ReactWrapper/instance.md b/docs/api/ReactWrapper/instance.md index 7b44e447c..03e9e46c3 100644 --- a/docs/api/ReactWrapper/instance.md +++ b/docs/api/ReactWrapper/instance.md @@ -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. diff --git a/docs/api/mount.md b/docs/api/mount.md index 4f8ca6f24..1352e26fc 100644 --- a/docs/api/mount.md +++ b/docs/api/mount.md @@ -174,8 +174,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. diff --git a/packages/enzyme/src/ReactWrapper.js b/packages/enzyme/src/ReactWrapper.js index 96f5f117c..2d6ebce10 100644 --- a/packages/enzyme/src/ReactWrapper.js +++ b/packages/enzyme/src/ReactWrapper.js @@ -191,9 +191,7 @@ 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: * ``` @@ -201,7 +199,7 @@ class ReactWrapper { * const inst = wrapper.instance(); * expect(inst).to.be.instanceOf(MyComponent); * ``` - * @returns {ReactComponent} + * @returns {ReactComponent|DOMComponent} */ instance() { if (this.length !== 1) {