From 5207bb7460459ba26f01fa4758f6e3c65e40191c Mon Sep 17 00:00:00 2001 From: David Date: Fri, 29 Jun 2018 08:15:57 +0200 Subject: [PATCH] update docs --- docs/api/ReactWrapper/exists.md | 14 +++++++++++--- docs/api/ShallowWrapper/exists.md | 16 ++++++++++++---- docs/api/mount.md | 4 ++-- docs/api/shallow.md | 4 ++-- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docs/api/ReactWrapper/exists.md b/docs/api/ReactWrapper/exists.md index 961febf00..78dfe0d01 100644 --- a/docs/api/ReactWrapper/exists.md +++ b/docs/api/ReactWrapper/exists.md @@ -1,11 +1,18 @@ -# `.exists() => Boolean` +# `.exists([selector]) => Boolean` + +Returns whether or not the current node exists. Or, if a selector is passed in, whether that selector has any matching results. + + + +#### Arguments + +1. `selector` ([`EnzymeSelector`](../selector.md) [optional]): The selector to check existence for. -Returns whether or not the current node exists. #### Returns -`Boolean`: whether or not the current node exists. +`Boolean`: whether or not the current node exists, or the selector had any results. @@ -14,5 +21,6 @@ Returns whether or not the current node exists. ```jsx const wrapper = mount(
); +expect(wrapper.exists('.some-class')).to.equal(true); expect(wrapper.find('.other-class').exists()).to.equal(false); ``` diff --git a/docs/api/ShallowWrapper/exists.md b/docs/api/ShallowWrapper/exists.md index 74ba91dcc..78dfe0d01 100644 --- a/docs/api/ShallowWrapper/exists.md +++ b/docs/api/ShallowWrapper/exists.md @@ -1,11 +1,18 @@ -# `.exists() => Boolean` +# `.exists([selector]) => Boolean` + +Returns whether or not the current node exists. Or, if a selector is passed in, whether that selector has any matching results. + + + +#### Arguments + +1. `selector` ([`EnzymeSelector`](../selector.md) [optional]): The selector to check existence for. -Returns whether or not the current node exists. #### Returns -`Boolean`: whether or not the current node exists. +`Boolean`: whether or not the current node exists, or the selector had any results. @@ -13,6 +20,7 @@ Returns whether or not the current node exists. ```jsx -const wrapper = shallow(
); +const wrapper = mount(
); +expect(wrapper.exists('.some-class')).to.equal(true); expect(wrapper.find('.other-class').exists()).to.equal(false); ``` diff --git a/docs/api/mount.md b/docs/api/mount.md index 4f8ca6f24..5c6f4aae8 100644 --- a/docs/api/mount.md +++ b/docs/api/mount.md @@ -90,8 +90,8 @@ Returns whether or not the current root node has the given class name or not. #### [`.is(selector) => Boolean`](ReactWrapper/is.md) Returns whether or not the current node matches a provided selector. -#### [`.exists() => Boolean`](ReactWrapper/exists.md) -Returns whether or not the current node exists. +#### [`.exists([selector]) => Boolean`](ReactWrapper/exists.md) +Returns whether or not the current node exists, or, if given a selector, whether that selector has any matching results. #### [`.isEmpty() => Boolean`](ReactWrapper/isEmpty.md) *Deprecated*: Use [.exists()](ReactWrapper/exists.md) instead. diff --git a/docs/api/shallow.md b/docs/api/shallow.md index a998639b5..fa1389505 100644 --- a/docs/api/shallow.md +++ b/docs/api/shallow.md @@ -97,8 +97,8 @@ Returns whether or not the current node has the given class name or not. #### [`.is(selector) => Boolean`](ShallowWrapper/is.md) Returns whether or not the current node matches a provided selector. -#### [`.exists() => Boolean`](ShallowWrapper/exists.md) -Returns whether or not the current node exists. +#### [`.exists([selector]) => Boolean`](ShallowWrapper/exists.md) +Returns whether or not the current node exists, or, if given a selector, whether that selector has any matching results. #### [`.isEmpty() => Boolean`](ShallowWrapper/isEmpty.md) *Deprecated*: Use [.exists()](ShallowWrapper/exists.md) instead.